android 圆角编辑框

 

main.xml:

 

[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:orientation="vertical"  
  4.     android:layout_width="fill_parent"  
  5.     android:layout_height="fill_parent"  
  6.     >  
  7.     <TextView    
  8.         android:layout_width="fill_parent"   
  9.         android:layout_height="wrap_content"  
  10.         android:gravity="center_horizontal"   
  11.         android:text="圆角编辑框"  
  12.     />  
  13.     <LinearLayout  
  14.         android:layout_width="fill_parent"  
  15.         android:layout_height="wrap_content"  
  16.         android:gravity="center_horizontal"  
  17.         android:orientation="horizontal">  
  18.           
  19.         <EditText  
  20.             android:layout_width="220px"  
  21.             android:layout_height="wrap_content"  
  22.             android:padding="5px"  
  23.             android:background="@drawable/rounded_edittext_states"   
  24.             android:drawableLeft="@drawable/search"  
  25.             android:singleLine="true"  
  26.             android:lines="1"  
  27.         />  
  28.           
  29.         <Button  
  30.             android:layout_width="wrap_content"  
  31.             android:layout_height="wrap_content"  
  32.             android:background="@drawable/button_search_bg"  
  33.         />   
  34.     </LinearLayout>  
  35. </LinearLayout>  
 

 

rounded_edittext_states.xml  :

[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <!-- res/drawable-hdpi/rounded_edittext_states.xml -->   
  3. <selector xmlns:android="http://schemas.android.com/apk/res/android">   
  4.     <item    
  5.         android:state_pressed="true"    
  6.         android:state_enabled="true"   
  7.         android:drawable="@drawable/rounded_focused" />   
  8.     <item    
  9.         android:state_focused="true"    
  10.         android:state_enabled="true"   
  11.         android:drawable="@drawable/rounded_focused" />   
  12.     <item    
  13.         android:state_enabled="true"   
  14.         android:drawable="@drawable/rounded_edittext" />   
  15. </selector>   
 

 

rounded_edittext.xml   :

 

[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <!--  res/drawable/rounded_edittext.xml -->   
  3. <shape xmlns:android="http://schemas.android.com/apk/res/android"   
  4.     android:shape="rectangle"   
  5.     android:padding="8dip">   
  6.     <solid android:color="#FFFFFF"/>   
  7.     <corners   
  8.         android:bottomRightRadius="10dip"   
  9.         android:bottomLeftRadius="10dip"   
  10.         android:topLeftRadius="10dip"   
  11.         android:topRightRadius="10dip"/>   
  12. </shape>  
 

 

rounded_edittext_focused.xml    :

 

[java]  view plain copy
  1. <?xml version="1.0" encoding="utf-8"?>   
  2. <!-- res/drawable/rounded_edittext_focused.xml -->   
  3. <shape xmlns:android="http://schemas.android.com/apk/res/android"   
  4.     android:shape="rectangle"   
  5.     android:padding="8dip">   
  6.     <solid android:color="#FFFFFF"/>   
  7.     <stroke android:width="2dip" android:color="#999" />   
  8.     <corners   
  9.         android:bottomRightRadius="10dip"   
  10.         android:bottomLeftRadius="10dip"   
  11.         android:topLeftRadius="10dip"   
  12.         android:topRightRadius="10dip"/>   
  13. </shape>   
 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值