Glasses this time, thought you'd get the sweater right away? I don't think so!
Wow, so once we’re in Android studio there is a lot of shit going on. If something didn’t load right or it’s telling you something is wrong, search the error or ask us in the comments. In this lesson we’re going to do a quickie tour and tweak some XML. The top bar has a bunch of buttons, if you hover over them for a second there will be a pop up telling you what it does. Below that is the navigation bar that shows us exactly where the open file is in the apps directory structure. Right now it’s the XML file for our activity. Below that is our projects file structure, by default it’s open to only show the files we edit in the app directory, but if you want to see you’re full project structure click the dropdown and select project. We’ll stick with android for now. The main directories we’re going to be working in are java which holds our main activity class, the brains of our app, and then the layout folder within res, short for resources, holds our main activity XML file that controls the layout of the home screen. It also holds launcher icons, images and other defaults for the app.
To the right of the project pane we have our text editor where all the magic happens. This is where we’ll be writing the sweet code to make our app run. Right now it’s design view, an interface for building the layout of our app. We can drag the widgets on the left side onto our phones screen. Then on the right side is our component tree that shows all the stuff on our screen. Right now it’s just the words hello world, which is a Textview. Views are kind of the generic term for any item we put into our apps layout. Below that is the properties of whatever view we have selected. If we wanted to make the text size of hello world bigger, select hello world by clicking on it, then click into the properties pane. If we just start typing text size it will automatically search for that property and we input 100 dp. Dp stands for device pixels which is a size measurement that helps standardize sizing across devices. If your phone is 1920x1080, like the nexus 5, you can’t use actual pixel measurements or your text will be ridiculously small, put in 12pix and you’ll see. (beat) What is this, an app for ants!!
Click the text display at the bottom, this is the XML creating our layout, the design view is just a preview of this file. Android uses XML for a lot of configuration files. XML is similar to HTML, but lets you make tags say whatever the hell you want. It gives you a consistent way to structure data with an opening and closing tag, plus attributes. The change we made to text size was applied to activity XML automatically. We can also edit the XML directly and the design view shows that change. Let’s make the text size 50 and look back at the design view. Ok cool, now our text is half the size.
Let’s do one last thing before we show you how to run this, get rid of that Action bar, we don’t need it. Click the manifests folder and open AndroidManifests dot xml. This file is a configuration for a bunch of stuff. We’re looking for apptheme. It’s prefixed with the @ sign and style which means it’s referencing a file in our resources directory called styles.xml. We’ll open this and edit the app theme line, delete Dark action bar and start typing NoActionBar, you’ll see autocomplete working for you! Thanks android studio. You can also hit control or command spacebar to see a list of autocomplete options.
But this is just a preview of the greatest app in the world, we can’t interact with our app on this screen. We need an emulator to run our app. An emulator creates a virtual phone on our computer, it’s not as good as the real thing, but it’s close and so convenient, you know like masturbation emulates actual sex, but just not quite as good.
Click the little phone icon which is the AVD manager. This is where we can create our Android Virtual Devices, or emulators. You can launch the default emulator by clicking the green play button next to it. But let’s run it from android studio. Close AVD and click the small green play button on the tool bar. If an emulator was already running we could choose it, but let’s choose launch emulator. Now this will be really, really, slow if you’re launching it for the first time. So be patient, Android Studio is building you a phone within your computer, a computer within a computer, an inception computer. We’ll fast forward, ok cool, we see our app!
In real life use an emulator called GenyMotion, it’s really easy to get started with and is waaaay faster than the emulators you create in Android studio. We’ll post links below. In the next lesson we’re gonna get our hands dirty laying out our app.
Go take the quiz! And hope that it's hot in here!