Android如何設定圓角按鈕

來源:互聯網
上載者:User

標籤:comment   檔案中   ext   顏色   version   add   tar   height   pad   

1. 在res目錄下的drawable目錄下建立shape.xml檔案

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="rectangle" >  
  4.   
  5.     <!-- 填充的顏色 -->  
  6.     <solid android:color="#FF065E8D" />  
  7.   
  8.     <!-- 設定按鈕的四個角為弧形 -->  
  9.     <!-- android:radius 弧形的半徑 -->  
  10.     <corners android:radius="15dip" />  
  11.   
  12.     <!-- padding:Button裡面的文字與Button邊界的間隔 -->  
  13.     <padding  
  14.         android:bottom="10dp"  
  15.         android:left="10dp"  
  16.         android:right="10dp"  
  17.         android:top="10dp" />  
  18. </shape>  

2.在布局檔案中調用。

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.     android:orientation="vertical" >  
  6.   
  7.     <Button  
  8.         android:id="@+id/roundButton"  
  9.         android:layout_width="wrap_content"  
  10.         android:layout_height="wrap_content"  
  11.         android:background="@drawable/shape"  
  12.         android:text="圓角按鈕" />  
  13. </LinearLayout>  

 

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.