<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ***** **自定義樣式** [TOC=6] # 1. selector ~~~ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true" android:drawable="@drawable/play_press" ;/> <item android:state_focused="true" android:drawable="@drawable/play_press" ;/> <item android:drawable="@drawable/play" ;/> </selector> ~~~ # 2. layer-list 使用layer-list可以將多個drawable按照順序層疊在一起顯示,默認情況下,所有的item中的drawable都會自動根據它附上view的大小而進行縮放, layer-list中的item是按照順序從下往上疊加的,即先定義的item在下面,后面的依次往上面疊放 例子: ~~~ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <shape android:shape="rectangle" > <solid android:color="#0000ff"/> </shape> </item> <item android:bottom="25dp" android:top="25dp" android:left="25dp" android:right="25dp"> <shape android:shape="rectangle" > <solid android:color="#00ff00" /> </shape> </item> <item android:bottom="50dp" android:top="50dp" android:left="50dp" android:right="50dp"> <shape android:shape="rectangle" > <solid android:color="#ff0000" /> </shape> </item> </layer-list> ~~~ 布局 ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <ImageView android:layout_width="150dp" android:layout_height="150dp" android:background="@drawable/layer_list"/> </LinearLayout> ~~~ 效果圖 ![](https://box.kancloud.cn/9fb3f2ae6d99e83a2eff8ab23752f1c8_214x213.png) 紅色item最后定義在最上方,綠色item中間,最先定義藍色最下邊 這里設置了android:bottom="50dp" android:top="50dp" android:left="50dp" android:right="50dp"屬性 android:top="50dp";表示該item上邊以ImageView上邊界往里面縮了50dp android:bottom="50dp"表示該item下邊以ImageView下邊界往里面縮了50dp android:left="50dp";表示該item左邊以ImageView左邊界往里面縮了50dp android:right="50dp";表示該item右邊以ImageView右邊界往里面縮了50dp android:bottom="25dp" android:top="25dp" android:left="25dp" android:right="25dp"類似 layer-list給指定view實現三面邊框 ~~~ <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.android.com/apk/res/android" > <item > <shape android:shape="rectangle" > <solid android:color="#ff0000"/> </shape> </item> <item android:bottom="2dp" android:top="2dp" android:right="2dp"> <shape android:shape="rectangle" > <solid android:color="#ffffff" /> </shape> </item> </layer-list> ~~~ 布局 ~~~ <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="150dp" android:layout_height="50dp" android:background="@drawable/border" android:layout_gravity="center" android:orientation="vertical" > </LinearLayout> </LinearLayout> ~~~ 效果圖 ![](https://box.kancloud.cn/83f0fee3e8491e084a109ac4376758fd_197x71.png) **實現帶陰影的按鈕效果:** ![](https://box.kancloud.cn/d81f6b63229e93633f4dfd38ceb5947f_1440x628.png) 代碼: ~~~ <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <!-- 灰色陰影 --> <layer-list> <item android:left="2dp" android:top="4dp"> <shape> <solid android:color="@android:color/darker_gray" /> <corners android:radius="4dp" /> </shape> </item> <!-- 紅色前景 --> <item android:bottom="4dp" android:right="2dp"> <shape> <solid android:color="#FF0000" /> <corners android:radius="4dp" /> </shape> </item> </layer-list> </item> <item> <!-- 灰色陰影 --> <layer-list> <item android:left="2dp" android:top="4dp"> <shape> <solid android:color="@android:color/darker_gray" /> <corners android:radius="4dp" /> </shape> </item> <!-- 白色前景 --> <item android:bottom="4dp" android:right="2dp"> <shape> <solid android:color="#FFFFFF" /> <corners android:radius="4dp" /> </shape> </item> </layer-list> </item> </selector> ~~~ ## 3. 樣式的使用 selector、layer-list、shpe 在style中定義樣式 配置樣式的地方 Application整個app Activity單獨的Activity
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看