Material Design Series Second article--getting Started

Source: Internet
Author: User

Getting Startedthis Lesson Teaches
    1. Apply the Material Theme
    2. Design Your Layouts
    3. Specify elevation in Your views
    4. Create Lists and Cards
    5. Customize Your Animations
You should also read
    • Material Design Specification
    • Material Design on Android

To create apps with material design:

    1. Review the material design specification.
    2. Apply the material theme to your app.
    3. Create your layouts following material design guidelines.
    4. Specify the elevation of your views to cast shadows.
    5. Use the system widgets for lists and cards.
    6. Customize the animations in your app.
Maintain backward compatibility

Can add many material design features to your apps while maintaining compatibility with versions of Android earlier tha N 5.0. For more information, see Maintaining compatibility.

Update your app with material design

To update a existing app to incorporate material design, update your layouts following material design guidelines. Also make sure to incorporate depth, touch feedback, and animations.

Create new apps with material design

If you is creating a new app with material design features, the material design guidelines provide your with a cohesive de Sign framework. Follow those guidelines and use the new functionality in the Android framework to design and develop your app.

Apply the Material Theme

To apply the material theme in your app, specify a style this inherits from android:Theme.Material :

<!--res/values/styles.xml-->   
<RESOURCES>
  <!-- Your theme inherits from the material theme-->
  < Style name = "Apptheme" parent = "android:Theme.Material" >
    <!-- theme Customizations -->
  </style>
</RESOURCES>

The material theme provides updated system widgets that let's set their color palette and default animations for touch F Eedback and activity transitions. For more details, see Using the Material Theme.

Design Your Layouts

In addition to applying and customizing the material theme, your layouts should conform to the material design guidelines. When you design your layouts, pay special attention to the following:

    • Baseline grids
    • Keylines
    • Spacing
    • Touch Target Size
    • Layout structure
Specify elevation in Your views

Views can cast shadows, and the elevation value of a view determines the size of its shadow and its drawing order. To set the elevation of a view with the android:elevation attribute in your layouts:

<textview   
    android:id = "@+id/my_textview"
    android:layout_width = "wrap_content"
    Android:layout_height = "wrap_content"
    android:text = "@string/next"
    android:background = "@color/white"
    android:elevation = "5DP" />

The new property translationZ lets your create animations that reflect temporary changes in the elevation of a view. Elevation changes can is useful when responding to touch gestures.

For more details, see Defining Shadows and Clipping views.

Create Lists and Cards

RecyclerViewis a more pluggable version of this ListView supports different layout types and provides performance improvements. CardView Let s you show pieces of information inside cards with a consistent look across apps. The following code example demonstrates how to include a in CardView your layout:

<android.support.v7.widget.cardview
Android:id = "@+id/card_view"
Android:layout_width = "200DP"
Android:layout_height = "200DP"
Card_view:cardcornerradius = "3DP" >
...
</android.support.v7.widget.CardView>

For more information, see Creating Lists and Cards.

Customize Your Animations

Android 5.0 (API level) includes the new APIs to the create custom animations in your app. For example, you can enable activity transitions and define a exit transition inside an activity:

 PublicclassmyactivityextendsActivity{

@Override
protectedvoidonCreate(Bundlesavedinstancestate){
Super.onCreate(savedinstancestate);
//Enable Transitions
GetWindow().requestfeature(Window.feature_content_transitions);
Setcontentview(R.Layout.activity_my);
}

Publicvoidonsomebuttonclicked(ViewView){
GetWindow().setexittransition(NewExplode());
IntentIntent=NewIntent( This,myotheractivity.class);
StartActivity(Intent,
activityoptions
.makescenetransitionanimation( This).Tobundle());
}
}

When you start another activity from this activity, the exit transition is activated.

To learn more on the new animation APIs, see Defining Custom animations.

Material Design Series Second article--getting Started

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.