码迷,mamicode.com
首页 > 移动开发 > 详细

android EditText设置光标、边框和图标

时间:2016-09-01 12:30:32      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

 

控制边框形状,先在drawable中建一个xml文件: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="#00ff00ff"/>  
4     <corners android:radius="8px"/>  
5     <stroke android:color="#32CD32"  
6         android:width="2px"  
7         />  
8 </shape>  

然后是布局文件,可以控制EditText的图标、字体颜色、光标、hint字体

 1 <?xml version="1.0" encoding="utf-8"?>  
 2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
 3     android:layout_width="fill_parent"  
 4     android:layout_height="fill_parent"  
 5     android:background="@drawable/bg"  
 6     android:orientation="vertical" >  
 7   
 8   
 9     <EditText   
10         android:layout_width="200dp"  
11         android:layout_height="wrap_content"  
12         android:layout_gravity="center"   
13         android:drawableLeft="@drawable/title"   //框内图标
14         android:background="@drawable/shape"  //边框形状
15         android:padding="5px"  
16         android:hint="请输入用户名"  
17         android:singleLine="true"      
18         android:textCursorDrawable="@null" //光标颜色        
19         android:textColor="#4e4d4d"/>  
20   
21 </LinearLayout>  
22     

 

android EditText设置光标、边框和图标

标签:

原文地址:http://www.cnblogs.com/Sharley/p/5829199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!