android shape的使用

來源:互聯網
上載者:User

標籤:布局   toc   nbsp   填充   tail   net   tco   str   art   

android shape的使用

然後在布局檔案裡面的Button裡面設定如下:

[java] view plain copy
  1. <Button  
  2.    android:id="@+id/button1"  
  3.    android:layout_width="wrap_content"  
  4.    android:layout_height="wrap_content"  
  5.    android:text="Button1"  
  6.    android:background="@drawable/buttonstyle" />  




shape用於設定形狀,可以在selector,layout等裡面使用,有6個子標籤,各屬性如下:

[java] view plain copy
    1. <?xml version="1.0" encoding="utf-8"?>  
    2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >  
    3.       
    4.     <!-- 圓角 -->  
    5.     <corners  
    6.         android:radius="9dp"  
    7.         android:topLeftRadius="2dp"  
    8.         android:topRightRadius="2dp"  
    9.         android:bottomLeftRadius="2dp"  
    10.         android:bottomRightRadius="2dp"/><!-- 設定圓角半徑 -->  
    11.       
    12.     <!-- 漸層 -->  
    13.     <gradient  
    14.         android:startColor="@android:color/white"  
    15.         android:centerColor="@android:color/black"  
    16.         android:endColor="@android:color/black"  
    17.         android:useLevel="true"  
    18.         android:angle="45"  
    19.         android:type="radial"  
    20.         android:centerX="0"  
    21.         android:centerY="0"  
    22.         android:gradientRadius="90"/>  
    23.       
    24.     <!-- 間隔 -->  
    25.     <padding  
    26.         android:left="2dp"  
    27.         android:top="2dp"  
    28.         android:right="2dp"  
    29.         android:bottom="2dp"/><!-- 各方向的間隔 -->  
    30.       
    31.     <!-- 大小 -->  
    32.     <size  
    33.         android:width="50dp"  
    34.         android:height="50dp"/><!-- 寬度和高度 -->  
    35.       
    36.     <!-- 填充 -->  
    37.     <solid  
    38.         android:color="@android:color/white"/><!-- 填充的顏色 -->  
    39.       
    40.     <!-- 描邊 -->  
    41.     <stroke  
    42.         android:width="2dp"  
    43.         android:color="@android:color/black"  
    44.         android:dashWidth="1dp"  
    45.         android:dashGap="2dp"/>  
    46.       
    47. </shape> 

android shape的使用

聯繫我們

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