Properties and use of Android layer-list

Source: Internet
Author: User

The properties and use of Android layer-list, layer-list is used for multiple layers stacked display, this feature can do some special effects (such as: Shadow, the following effect, etc.), can also be opportunistic.

1. Code slices

<?xml version= "1.0" encoding= "Utf-8"? ><layer-list xmlns:android= "http://schemas.android.com/apk/res/ Android >    <!--The most recent projects require multiple layers stacked together to study the layer-list in Android. The Layer-list in Android is used to display multiple layers stacked. -    <item>      <shape > <!--the first layer is blue--          <solid android:color= "@color/blue"/>      </shape>    </item>        <!--the second layer of color, which is the topmost layer, because the second layer    moves up two DP relative to the bottom of the view, so the first layer will reveal a DP of black so         gives the illusion of a bottom border--    <item android:bottom= "2dip" >        <shape>            <solid android:color= "@color/white"/>        </shape>    </item></layer-list>

2. Layout code and (be sure to note the use of Radiogroup to remember the write RadioButton ID, otherwise cannot switch )

    <radiogroup android:id= "@+id/rg" android:layout_below= "@id/bt2" android:layout_margin= "10dip" Android:layout_width= "Match_parent" android:layout_height= "wrap_content" android:orientation= "Horizo        Ntal "> <radiobutton android:id=" @+id/rb0 "android:layout_height=" Wrap_content "        Android:layout_width= "0dip" android:layout_weight= "1" android:button= "@null" android:text= "category" Android:checked= "true" android:gravity= "center" android:textcolor= "@color/black" android:background= "@drawable/ch_bg" android:layout_margintop= "2dip" android:paddingbottom= "4dip"/> <radio        Button android:id= "@+id/rb1" android:layout_height= "wrap_content" android:layout_width= "0dip" android:layout_weight= "1" android:text= "category" Android:button= "@null" android:gravity= "center" a Ndroid:textcolor= "@color/black "android:background=" @drawable/ch_bg "android:layout_margintop=" 2dip "android:paddingbottom=" 4 Dip "/> </RadioGroup>

Selector Selector

<?xml version= "1.0" encoding= "Utf-8"? ><selector xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item android:state_checked=" true "android:drawable=" @drawable/bg_li "></item>    <item android:state_checked= "false" android:drawable= "@color/white" ></item></selector>



3. Code slices

<?xml version= "1.0dip" encoding= "Utf-8"? ><layer-list xmlns:android= "http://schemas.android.com/apk/res/ Android ">    <item>        <bitmap android:src=" @drawable/ic_launcher "            android:gravity=" center "/ >    </item>    <item android:left= "10dip" android:top= "10dip" >        <bitmap android:src= "@ Drawable/ic_launcher "            android:gravity=" center "/>    </item>    <item android:left=" 20dip " android:top= "20dip" >        <bitmap android:src= "@drawable/ic_launcher"            android:gravity= "center"/>    </item>    <item android:left= "30dip" android:top= "30dip" >        <bitmap android:src= "@ Drawable/ic_launcher "            android:gravity=" center "/>    </item></layer-list>


4. Code slices

<?xml version= "1.0" encoding= "Utf-8"? ><layer-list xmlns:android= "http://schemas.android.com/apk/res/ Android ">        <item android:drawable=" @drawable/ic_launcher "></item>    <item android:left=" 10dip "android:top=" 10dip "android:drawable=" @drawable/ic_launcher "></item>    <item android:left=" 20dip "android:top=" 20dip "android:drawable=" @drawable/ic_launcher "></item>    <item android:left=" 30dip "android:top=" 30dip "android:drawable=" @drawable/ic_launcher "></item></layer-list>

5. Knowledge Base Connection:

http://blog.csdn.net/brokge/article/details/9713041
Http://www.aitinan.com/4004.html
Http://www.cnblogs.com/tsoorr/p/3407935.html
Http://www.cnblogs.com/ithouge/articles/ithouge-android-layer-list-shape-corners.html
Http://www.linuxidc.com/Linux/2012-05/59827.htm


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Properties and use of Android layer-list

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.