1.4: Learn to help yourself
In this codelab, you learn about resources that are helpful to Kotlin Android developers, including templates, documentation, videos, and sample apps.
First you create a simple app from an Android Studio template and modify the app. Then you download and explore the Android Sunflower sample app. You replace the sample app’s launcher icon (a sunflower) with a clip-art image asset that’s available within Android Studio (a smiley face).
3. Task: Use project templates
Architecture of the Basic Activity template
# | UI description | Code reference |
---|---|---|
1 | Status bar, which the Android system provides and controls. | Not visible in the template code, but you can access the status-bar from your activity. |
2 | The app bar, also called the action bar, provides visual structure, standardized visual elements, and navigation. | In activity_main.xml , look for Toolbar inside the AppBarLayout element. For backward compatibility, the AppBarLayout in the template embeds a Toolbar that has the same functionality as an ActionBar .To change the appearance of the app bar, change the toolbar attributes. For app bar tutorials, see Add the app bar. |
3 | The app name is initially derived from your package name, but you can change it to anything you want. | In AndroidManifest.xml , look for android:label="@string/app_name" .Specify the app_name string in strings.xml . |
4 | The options-menu overflow button holds menu items for the activity. The overflow button also holds global menu options such as Search and Settings for the app. Your app menu items go into this menu. | In MainActivity.kt , the onOptionsItemSelected() method implements what happens when the user selects a menu item.To see the options-menu items, open the res/menu/menu_main.xml file. Only the Settings menu item is specified in this template. |
5 | The CoordinatorLayout ViewGroup is a layout that provides mechanisms for UI elements to interact. Your app’s UI goes inside the content_main.xml file, which is included within this ViewGroup . | In activity_main.xml , look for the include layout instruction. No views are specified in this layout; instead, the layout includes the content_main layout, where the app’s views are specified. System views are kept separate from the views unique to your app. |
6 | The template uses a TextView to display “Hello World”. | The “Hello World” text view is in the content_main.xml file. All your app’s UI elements should be defined in this file. |
7 | Floating action button (FAB) | In activity_main.xml , look for the FloatingActionButton element. The FAB is defined as a UI element using a clip-art icon. MainActivity.kt includes a stub in onCreate() that sets an onClick() listener for the FAB. |
5. Task: Explore docs and other resources
Go to developer.android.com. This official Android developer documentation is kept current by Google.
Go to developer.android.com/design/. This site offers guidelines for designing the look and functionality of high-quality Android apps.
Go to material.io, which is a site about Material Design. Material Design is a conceptual design philosophy that outlines how all apps, not just Android apps, should look and function on mobile devices. Navigate the links to learn more about Material Design. For example, to learn about the use of color, click the Design tab, then select Color.
Go to developer.android.com/docs/ to find API information, reference documentation, tutorials, tool guides, and code samples.
Go to developer.android.com/distribute/ to find information about publishing an app on Google Play. Google Play is Google’s digital distribution system for apps developed with the Android SDK. Use the Google Play Console to grow your user base and start earning money.
Explore the Android Developer YouTube channel, which is a great source of tutorials and tips.
Visit the official Android blog, where the Android team posts news and tips.
Enter a question into Google Search, and the Google Search engine collects relevant results from various resources. For example, use Google Search to ask the question, “What is the most popular Android OS version in India?” You can even enter error messages in Google Search.