`
wang_peng1
  • 浏览: 3904483 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

EditText圆角设置

阅读更多

<?xml version="1.0" encoding="utf-8"?> 
<!--  res/drawable/rounded_edittext.xml --> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" android:padding="10dp"> 
 
<solid android:color="#FFFFFF"/> 
   
<corners 
     
android:bottomRightRadius="15dp" 
     
android:bottomLeftRadius="15dp" 
 
android:topLeftRadius="15dp" 
 
android:topRightRadius="15dp"/> 
</shape>

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
   
android:orientation="vertical" 
   
android:layout_width="fill_parent" 
   
android:layout_height="fill_parent" 
   
> 
<EditText   
   
android:layout_width="fill_parent"  
   
android:layout_height="wrap_content"  
   
android:padding="5dip" 
   
android:background="@drawable/rounded_edittext" /> 
</LinearLayout> 
你也可以设置不同的编辑状态

<?xml version="1.0" encoding="utf-8"?> 
<!-- res/drawable/rounded_edittext_states.xml --> 
<selector xmlns:android="http://schemas.android.com/apk/res/android"> 
   
<item  
     
android:state_pressed="true"  
     
android:state_enabled="true" 
       
android:drawable="@drawable/rounded_focused" /> 
   
<item  
     
android:state_focused="true"  
     
android:state_enabled="true" 
       
android:drawable="@drawable/rounded_focused" /> 
   
<item  
     
android:state_enabled="true" 
       
android:drawable="@drawable/rounded_edittext" /> 
</selector> 
<?xml version="1.0" encoding="utf-8"?> 
<!-- res/drawable/rounded_edittext_focused.xml --> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" android:padding="10dp"> 
 
<solid android:color="#FFFFFF"/> 
 
<stroke android:width="2dp" android:color="#FF0000" /> 
   
<corners 
     
android:bottomRightRadius="15dp" 
     
android:bottomLeftRadius="15dp" 
 
android:topLeftRadius="15dp" 
 
android:topRightRadius="15dp"/> 
</shape> 
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
   
android:orientation="vertical" 
   
android:layout_width="fill_parent" 
   
android:layout_height="fill_parent"> 
<EditText   
   
android:layout_width="fill_parent"  
   
android:layout_height="wrap_content"  
   
android:text="@string/hello" 
   
android:background="@drawable/rounded_edittext_states" 
   
android:padding="5dip"/> 
</LinearLayout> 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics