Add Code from a Template
Android Studio provides code templates that help you create new projects with a certain design pattern or to add components to your existing project. The code templates follow the Android design and development guidelines to get you on the right track to creating a beautiful, functional application.
There are several types of Android code templates, which can create anything from an entire application down to specific application components. The main categories of code templates are as follows:
The templates use support library objects if such objects are available. The support library objects make new features available on the widest range of platforms. For example, since the templates use theappcompat library, apps based on the templates use material design user interface principles even if they are running on older Android devices that do not directly support material design.
Application Templates
Application templates create basic Android application modules that you can immediately run and test on your Android device. These templates are available when you create a new Android module, though you can also use these templates to add new activities to an existing module.
To use Android application templates:
- In Android Studio, select File > New > Module.
- Enter the settings for your application, including Application Name, Company Domain, Package name, and minimum SDK, then click Next.
- Select an application template to use, then click Next. For example,
- Enter the settings for your activity, including Activity Name, layout Name, Title, and Menu Resource Name, then click Finish.
Note: The other activity template options also create applications, however these applications require further modification before they can be launched on an Android device.
Blank Activity Template
Example | Description |
---|---|
The BlankActivity template with the Navigation Type: None option creates a simple application that follows the Android Design guidelines. Use this template to create a basic, minimal app as a starting point for your project. This template includes:
| |
The BlankActivity template with the Navigation Type: Tabs or Tabs + Swipe option creates an application with three sections based on the This template includes:
| |
The BlankActivity template with the Navigation Type: Swipe Views + Title Strip option creates an application with three This template includes:
| |
The BlankActivity template with the Navigation Type: Dropdown option creates an application that extends This template includes: |
Full Screen Activity Template
Example | Description |
---|---|
This template provides an implementation of an activity which alternates between a primary, full screen view and a view with standard user interface controls, including the notification bar and application title bar. The full screen view is the default and a user can activate the standard view by touching the device screen. This template includes:
|
Master Detail Flow Template
Example | Description |
---|---|
This template creates an adaptive layout for a set of items and associated details. On a tablet device, the item list and item details are displayed on the same screen. On a smaller device, the list and details are displayed on separate screens. Note: This template follows the recommendations of the Designing for Multiple Screens Android training. This template includes:
|
Activity Templates
Android activity templates provide options to add new activities to your existing application.
To use Android activity templates:
- Right click the project folder of the Android application where you want to add an activity.
- Select New > Other...
- Select Android > Android Activity, then click Next.
- Select an activity template, then follow the instructions to add it to your existing application.
These templates create the same type of activity as they do when used as an application template, however the following templates create activities which are specifically intended to be used as part of an existing application.
Login Activity Template
Example | Description |
---|---|
This activity template provides input fields and a sample implementation of an This template includes:
|
Settings Activity Template
Example | Description |
---|---|
This template extends the This template includes:
|
Other Templates
Android object templates provide options to add new components to your existing application, including the previously mentioned activities as well as the following additional items:
To use Android object templates:
- Right-click the module folder of the Android application where you want to add a code component.
- Select New
- Select the object type and template, then follow the instructions to add it to your existing application.
- AIDL
- Activity
- Folder
- Fragment
- Other
- Service
- UI Component
- Wear
- Widget
- XML
'User Guide' 카테고리의 다른 글
Lint로 코드 개선하기 Improve Your Code with Lint (11) (0) | 2016.06.02 |
---|---|
app 만들기 Write Your App (10) (0) | 2016.06.01 |
안드로이드 라이브러리 만들기 Create an Android Library (8) (0) | 2016.06.01 |
프로젝트 또는 App모듈 만들기 Create a Project or App Module (7) (0) | 2016.06.01 |
프로젝트 관리 Manage Your Project (6) (0) | 2016.06.01 |
댓글