Android layer-list的屬性和使用具體解釋

來源:互聯網
上載者:User

標籤:布局   lan   button   tom   add   linu   encoding   www   pos   

Android layer-list的屬性和使用具體解釋。layer-list是用來多個圖層堆疊顯示的,借這個特效能夠做一些特別的效果(比方:陰影、以下的效果等),也能夠投機取巧。

1.代碼片

<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <!--近期的項目中須要用到多個圖層堆疊到一塊兒,就研究了一下android中的layer-list。android中的layer-list就是用來多個圖層堆疊顯示的。 -->    <item>      <shape > <!-- 第一層的顏色為藍色 -->          <solid android:color="@color/blue"/>      </shape>    </item>        <!-- 第二層的顏色。也就是最上面的一層,由於第二層相對於    View的底部上移兩個dp所以第一層會露出一個dp的黑色所以         給人一種僅僅有底部邊框的假象 -->    <item android:bottom="2dip">        <shape>            <solid android:color="@color/white"/>        </shape>    </item></layer-list>

2.布局代碼和 (一定要注意在使用RadioGroup的時候要記的寫RadioButton的id,否則不能切換)

    <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="horizontal">                <RadioButton         android:id="@+id/rb0"        android:layout_height="wrap_content"        android:layout_width="0dip"        android:layout_weight="1"        android:button="@null"        android:text="分類"        android:checked="true"        android:gravity="center"        android:textColor="@color/black"        android:background="@drawable/ch_bg"        android:layout_marginTop="2dip"        android:paddingBottom="4dip"/>                <RadioButton         android:id="@+id/rb1"        android:layout_height="wrap_content"        android:layout_width="0dip"        android:layout_weight="1"        android:text="分類"        android:button="@null"        android:gravity="center"        android:textColor="@color/black"        android:background="@drawable/ch_bg"        android:layout_marginTop="2dip"        android:paddingBottom="4dip"/>            </RadioGroup>

選取器

<?

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.代碼片

<?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.代碼片

<?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.知識庫串連:

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


Android layer-list的屬性和使用具體解釋

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.