There are common UI components between Apple and Android. Learn about these and how to work with them—both in XML and the Android version of Interface Builder.
- [Man] To talk about working with U.I. in Android, I've created a project under the exercise files, chapter six, six oh one. And, it's called Android U.I. Let's go ahead and copy that, and put it into our projects folder. Right mouse click it, option click, and get that path name and then we'll open this up in Android Studio. Click Okay. And now, we're in the layout file for our first activity.
We've got a lot of components to pull from here. And it's just as easy as clicking on a button and pulling it in to our main view. Let's go ahead and pull in an image type, as well in here. So, it's in image view, and in fact, all of these are descendants of views. So they all say text view, image view. Let's go ahead and select Adam Smith as that image, and we'll say the size is 100 D.P., 100 D.P.
If you look on the screen we have two different views here. One of these is the layout view and the other is the constraint view. And these constraints are really similar to constraints in IOS. But, they're a lot easier to work with, and to see what's going on. So, first, you can move these around, but they aren't really constrained; except for this text you can already see that this jagged line is saying it's constrained to a certain amount here, and all along this. So, in this view, let's go ahead and zoom in a little bit.
Hit command one to collapse that. You'll want as much real estate working with this as possible. And, you can see that we have these different circles that kind of tell us where we are connected to. If I click on that bottom one it'll remove that constraint. And clicking on any of these with remove the constraints. Adding the constraints is just as easy, though. All you have to do is click again on that circle and pull to where you want it constrained to. I'm going to constrain it to the sides, as well as the top, and if I want it to fill I can click on these chevrons, and it'll either move to a specific width for it.
Again, this changes to zero D.P. And this just says "match constraints". And, so, the whole text field will spread all the way across. If we want to constrain this button down to the bottom right, we can just click and drag in both places. And this image, view, I'm going to just constrain it to here, as well as to that right margin of this text view. If you're interested in learning more about U.I. views and constraints within Android there's a great course called Android Development Essential Training: Design a User Interface by David Gassner.
- Creating an Android emulator
- Similarities and differences between Kotlin and Swift
- Lambdas and exceptions
- Working with external extensions
- Extension collisions
- Using Java classes within Kotlin
- Working with network calls using Retrofit
- Writing a method to GET from the server
- Threading with AsyncTask
- Threading with RxJava
- Common UI components between Apple and Android
- Adding UI events
- Creating an activity