Android 利用Sharp樣式設置文本框EditText圓角形狀


1.首先新建樣式文件editsharp.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 <!--     <gradient  6         android:angle="45"
 7         android:endColor="#CCCCCC"
 8         android:startColor="#CCCCCC" /> -->
 9 
10     <padding 11         android:bottom="7dp"
12         android:left="7dp"
13         android:right="7dp"
14         android:top="7dp" />
15     <!-- 設置圓角矩形 -->
16     <corners android:radius="3dp" />
17 
18     <stroke 19         android:width="5px"
20         android:color="#1199EF" />
21 
22     <solid android:color="#CCCCCC" />
23 
24 </shape>

2.在布局文件中引用樣式文件:

    <EditText
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="20dp"
        android:background="@drawable/editsharp" />

3.文本框效果圖如下:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM