歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android UI---自定義形狀shape

Android UI---自定義形狀shape

日期:2017/3/1 10:12:16   编辑:Linux編程

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. <solid android:color="#ffffffff" />
  4. <corners android:radius="10dp" />
  5. <padding
  6. android:bottom="10dp"
  7. android:left="5dp"
  8. android:right="5dp"
  9. android:top="5dp" />
  10. <stroke
  11. android:width="2dp"
  12. android:color="#ff00bbe8" >
  13. </stroke>
  14. </shape>

2、在需要的地方調用:

  1. <EditText
  2. android:id="@+id/mText"
  3. android:layout_width="fill_parent"
  4. android:layout_height="100px"
  5. android:background="@drawable/shape"
  6. android:textColor="#aa000000"
  7. android:textSize="20dp"
  8. android:gravity="top"
  9. android:layout_margin="3dp"
  10. android:paddingLeft="10dp"
  11. android:paddingRight="10dp"/>

、看下效果圖:

Copyright © Linux教程網 All Rights Reserved