App Layout in Android Studio - Android Virgin Lesson 3

  • 6年前
Android gets me söo hot, you too?\r
\r
In this lesson were going to setup the layout of our pickup app. Here is what our app will look like, two buttons to get clean and dirty pickup lines, and then another screen to display the pickup line, along with a button to try again if theyre not that into you, but im sure they will be. The first layout is set up with the main ivities XML file.\r
\r
So delete hello world by clicking on it and pressing delete, we can also select stuff in the component tree view to the right. Now weve got a blank canvas, select the text view. Were going to change the layout to Linear layout and delete this padding, notice that its highlighted green, this means its referencing another file, if we click on it we see the @ sign, in this case the dimens dot xml in the values folder. Thats a file where you can standardize dimensions. Android handles a lot of defaults this way and when you see an @ sign that means its referencing a file somewhere. For now delete the padding, for this app we dont need more cushion for the pushin. Next well add the attribute android orientation vertical, to make whatever we put into this layout arrange itself vertically. Look back at the design view and well see the padding is gone.\r
\r
Lets split this vertical layout into two halves by adding two relative layouts. Select relative layout, then mouse over linear layout in the component tree and click to add it. You dont need to drag, but you can. Do it one more time for the second half. We dont see much change in the design, to make each relative layout take up half the screen find layout weight in properties and change it to .5, linear layout allows you to weight things inside, weight of 0.5 tells each relative layout to take up half the space.

推荐视频