android shape,android

來源:互聯網
上載者:User

android shape,android
android shape 畫邊框,指定某一邊

android要實作類別似網頁中的表格還帶有邊框的時候,這個邊框還是不太好處理,有的時候四個邊有的邊有邊線有的邊線沒有,處理方法如下:

  • shape之inset
<?xml version="1.0" encoding="utf-8"?><!--畫一個邊線,四個邊框只有上面沒有邊框--><inset        xmlns:android="http://schemas.android.com/apk/res/android"        android:insetTop="-1dp">    <!--形狀-->    <shape android:shape="rectangle">        <!--填充顏色-->        <solid android:color="@color/transparent"></solid>        <!--描邊-->        <stroke android:width="1.0dp" android:color="@color/te6e6e6"></stroke>        <!--paddint-->        <padding android:left="0dp" android:right="0dp" android:top="0dp" android:bottom="0dp"></padding>        <!--圓角-->        <corners android:radius="0dp"/>    </shape></inset>

詳情可以查看Android XML Drawable – Only Top & Bottom Border

  • shape之select 用於有多種狀態的組件,如checkbox,radio,checkTextview
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:drawable="@drawable/ac_order_check_press" android:state_checked="true"/>    <item android:drawable="@drawable/ac_order_check_normal"/></selector>
  • 圓角非圓角空心非實心有邊線的無邊線的
<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item>        <!--形狀-->        <shape android:shape="rectangle">            <!--填充顏色-->            <solid android:color="@color/t4ec68d"></solid>            <!--描邊-->            <stroke android:width="0.8dp" android:color="@color/bbutton_title_edge"></stroke>            <!--paddint-->            <padding android:left="5dp" android:right="5dp" android:top="2dp" android:bottom="2dp"></padding>            <!--圓角-->            <corners android:radius="4dp"/>        </shape>    </item></selector>

有多種狀態的

<?xml version="1.0" encoding="utf-8"?><selector xmlns:android="http://schemas.android.com/apk/res/android">    <item android:state_checked="true">        <shape>             <!--填充顏色-->            <solid android:color="@color/bbutton_title_pressed"/>             <!--描邊-->            <stroke android:width="1dp" android:color="@color/bbutton_title_edge"/>            <padding android:left="5dp" android:right="5dp" android:top="2dp" android:bottom="2dp"></padding>            <!--圓角-->            <corners android:radius="4dp"/>        </shape>    </item>    <item android:state_enabled="false">        <shape>            <solid android:color="@color/bbutton_title_disabled"/>            <stroke android:width="1dp" android:color="@color/bbutton_title_disabled_edge"/>            <padding android:left="5dp" android:right="5dp" android:top="2dp" android:bottom="2dp"></padding>            <corners android:radius="4dp"/>        </shape>    </item>    <item android:state_checked="false">        <shape>            <solid android:color="@color/bbutton_title_disabled"/>            <stroke android:width="1dp" android:color="@color/bbutton_title_disabled_edge"/>            <padding android:left="5dp" android:right="5dp" android:top="2dp" android:bottom="2dp"></padding>            <corners android:radius="4dp"/>        </shape>    </item>    <item>        <shape android:shape="rectangle">            <solid android:color="@color/bbutton_title"></solid>            <stroke android:width="0.8dp" android:color="@color/bbutton_title_edge"></stroke>            <padding android:left="5dp" android:right="5dp" android:top="2dp" android:bottom="2dp"></padding>            <corners android:radius="4dp"/>        </shape>    </item></selector>

對應的color的顏色值

<resources>    <?xml version="1.0" encoding="utf-8"?>       <!--空心的藍色邊框的按鈕-->    <color name="bbutton_blue_title">#00ffffff</color>    <color name="bbutton_blue_title_edge">#0081cc</color>    <color name="bbutton_blue_title_pressed">#00ffffff</color>    <color name="bbutton_blue_title_pressed_edge">#0081cc</color>    <color name="bbutton_blue_title_disabled">#00ffffff</color>    <color name="bbutton_blue_title_disabled_edge">#B4B4B4</color></resource>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.