第三章,設定button邊框(Android)

來源:互聯網
上載者:User

標籤:src   context   img   item   --   text   分享   round   sdn   

這樣的方法是通過層疊幾個圖片實現邊框效果。

在res目錄下的drawable目錄下(沒有就建立)建一個xml檔案選layer-list。

<?xml version="1.0" encoding="UTF-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android" >    <!--         與順序有關。最外層一定要放在最前面。最裡層放在裡面,         不然會被遮擋。也與item中設定的值大小有關係-->    <!-- 最外層 -->    <item>        <shape>            <solid android:color="#1e90ff" />        </shape>    </item>    <!-- 中介層 -->    <item        android:bottom="15dp"        android:left="15dp"        android:right="15dp"        android:top="15dp">        <shape>            <solid android:color="#ffffff" />        </shape>    </item>    <!-- 最裡層 -->    <item        android:bottom="30dp"        android:left="30dp"        android:right="30dp"        android:top="30dp">        <shape>            <solid android:color="#bebebe" />        </shape>    </item></layer-list>
布局檔案:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent"    tools:context=".MainActivity"    android:orientation="horizontal"     >    <Button        android:id="@+id/main_button"        android:layout_width="match_parent"        android:layout_height="137dp"        android:background="@drawable/buttonl"        android:text="button01" /></LinearLayout>
效果:



第三章,設定button邊框(Android)

聯繫我們

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