Android5.0 New Controls

Source: Internet
Author: User

Google introduced a number of new controls at the same time as the launch of Android5.0, with the following 5 of the most commonly used new controls in Android5.0.

1. CardView (Card view)

CardView, as its name implies, is a card view that inherits Framelayout. It is a background with rounded corners and a shadow framelayout. CardView is packaged as a layout and is often used as a container in the ListView and Recyclerview item layouts.
CardView is very simple to use:

1<Android.support.v7.widget.CardView2Android:layout_width="match_parent"3android:layout_height="60DP">4<Button5Android:id="@+id/ripple_button"6Android:layout_width="match_parent"7android:layout_height="50DP"8android:layout_gravity="Center"9android:layout_margin="5DP"TenAndroid:background="@drawable/ripple" Oneandroid:gravity="Center" Aandroid:text="I'm in a CardView ."/> -</android.support.v7.widget.CardView>

2. Patelle (color palette)

Patelle is an auxiliary class that is useful for getting prominent colors from pictures.
It can extract the highlighted colors of the following features:
-Vibrant (vibrant)
-Vibrant Dark (vibrant, dark)
-Vibrant light (vibrant, bright)
-Muted (soft)
-Muted Dark (soft, dark)
-Muted light (soft, bright)

Patelle is also very simple to use:

1  // get the application icon bitmap 2 bitmap= Bitmapfactory.decoderesource (getresources (), r.mipmap.ic_launcher); 3 // generate a palette from bitmap palette 4 Palette Palette=palette.  from (bitmap). Generate (); 5 // Get palette Vibrant color 6 int vibrantcolor=palette.getvibrantcolor (color.white);  
3. Toolbar (Toolbar)

Toolbar as the name implies is the toolbar, as a substitute for actionbar appear, Google recommends the use of toolbar replacement actionbar.
Toolbar can be placed anywhere, not as actionbar can be placed in a fixed position.
Toolbar supports features that are more concentrated than Actionbar.
Toolbar may contain a combination of the following optional elements:
-Navigation buttons
-logo image of the brand
-Title and sub-headings
-One or more custom views

1  This. toolbar =(Toolbar) Findviewbyid (R.id.toolbar);2  This. Recyclerview =(Recyclerview) Findviewbyid (R.id.recycler_view);3  This. Ripplebutton =(Button) Findviewbyid (R.id.ripple_button);4  This. Button =(Button) Findviewbyid (R.id.button);5 //Set logo6 Toolbar.setlogo (r.mipmap.ic_launcher);7 //Set Title8Toolbar.settitle ("Android5.0");9 //set sub-headingsTenToolbar.setsubtitle ("New Controls"); One //set the Actionbar, then you can get the Actionbar and operate, the result of the operation will be reflected on the toolbar A Setactionbar (toolbar); - //set the return arrow, which is equivalent to setting the toolbar navigation button -Getactionbar (). setdisplayhomeasupenabled (true);

4. Rippledrawable (Ripple Chart)

Rippledrawable as the name implies is a ripple diagram, can only be used above the Android5.0, there is no rippledrawable backward compatible support package.
The rippledrawable can show a ripple effect response state change.
Defines a background picture of a UI as Rippledrawable
android:background="@drawable/ripple"
Define a rippledrawable XML file under the Drawable folder

<?xml version="1.0"encoding="Utf-8"? ><ripple xmlns:android="http://schemas.android.com/apk/res/android"Android:color="#0000FF"> <item> <shape android:shape="Rectangle"> <solid android:color="#FFFFFF"/> <corners android:radius="4DP"/> </shape> </item></ripple>

android:color: Color to indicate ripple
<item>: Represents the entry below the ripple graph

Take a look at the ripple effect of the click button

5. Recyclerview (Loop view)

Recyclerview is a replacement for the ListView, and Google recommends using Recyclerview instead of the ListView.
The Recyclerview provides more flexible use than a ListView and has better performance than a ListView.
Recyclerview can set linear, grid, waterfall streaming three layout manager.
-Linearlayoutmanager (Linear layout manager)
-Gridlayoutmanager (Grid layout manager)
-Staggeredgridlayoutmanager (Waterfall Flow layout manager)

Note: The Recyclerview,patelle,cardview is inside a separate support package, not appcompat-v7 and its dependent child subpackages

To use them, you must import their dependent packages

  ' com.android.support:recyclerview-v7:23.1.1 '   ' com.android.support:palette-v7:23.1.1'          com.android.support:cardview-v7:23.1.1 '  

Android5.0 New Controls

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.