This blog post will chronicle my relearning of Android Studio.
I recently applied for a contract to develop an Android application that sounds almost exactly like an app I was considering developing for a family friend! I’m still waiting to hear back after their initial email reply, so in the meantime, and regardless of whether I get the job, I’m going to relearn the ins and outs of Android studio!
I like Java, and I did really well with my XML course, so I’m actually pretty psyched to get back to developing by using these 2 languages.
This post will chronicle some of the important lessons I extract from the free course that the Android Studio people provide through Udacity. This is actually one of the best tutorials for learning a development system that I’ve ever come across, and I hope others can copy Google here (obviously this would cost them lots of money which other frameworks and systems can’t just give away, but still, I like it and I want it!).
Create Project Sunshine
- The minSDK is the lowest SDK level the app can run on, so the lower the more users can be reached, but the less features can be extracted. It seems possible from this documentation to set a low minSDK, but then use a higher test SDK later and for production to get different features out.
- Further to above, once your app is deployed, you should test and update your app to work on later SDKs when they are released to take advantage of new features and optimisations
Activity
- Activity is basically a screen, but more accurately, it is a ‘single focused thing that a user can do’.
Activities are responsible for creating the window that your application uses to draw and receive events from the system.
- So this is why every page (basically) is referred to as an activity in Android Studio. This distinction will probably be starker as you get more complex, and hence ‘page’ will not be synonymous with
- Each activity contains layout
- Activity layouts are stored in xml format
- The apps resources are abstracted away from code in the ‘res’ folder to make apps transposable to different machines
Views
An Android UI class in Java, views are rectangular areas that display and receive events; they are the viewable interactive pieces – all the components the user visually sees and interacts with
- Views come in 2 categories: UI component views & ‘container’ or ‘layout’ views.
Table 1 – Example UI View Components. Retrieved from Udacity
Class Name |
Description |
Creates text on the screen; generally non interactive text. |
|
Creates a text input on the screen |
|
Creates an image on the screen |
|
Creates a button on the screen |
|
Create a simple timer on screen |
Table 2 – Example Container Views. Retrieved from Udacity
Class Name |
Description |
Displays views in a single column or row. |
|
Displays views positioned relative to each other and this view. |
|
A ViewGroup meant to contain a single child view. |
|
A FrameLayout that is designed to let the user scroll through the content in the view. |
|
This is a newer viewgroup; it positions views in a flexible way. |
Some very important attributes for layout views
- Wrap_content will shrink the view in question to wrap the content within, i.e. it will shrink to view to be exactly large enough, and no larger, to fit what is in the view
- Match_parent: will expand the size – or rather, width – of the view to be as large as the parent view which it is nested inside of
- When setting precise sizes, it is typically better to use dp instead of p. dp are density independent pixels, so they are more responsive.
Container Views
- Frame Layout – is good for simple layouts with only a single view within, such as a scrolling list that should take up the screen?
- Linear Layout – is good for stacking views horizontally or vertically within
- Constraint layout – more complex, suitable for more responsive designs
These were the main takeaways from lesson 1:
- Basic layouts
- The folder structure – layouts and UI resources are in the res folder, whilst operability is done with java in the activities folder