本文实例讲述了android2.3实现android4.0风格edittext的方法。分享给大家供大家参考,具体如下:
效果如下:
思路:在源码里找到4.0风格的图片作为背景,xml文件定义点击时候边框变化
步骤:
1.在
d:\android\android-sdk-windows\android-sdk-windows\platforms\android-14\data\res\drawable-xhdpi
目录下找到图片文件:
textfield_disabled_holo_light.9.png:
textfield_multiline_activated_holo_dark.9.png:
2.
在drawable文件夹下建立edittext_change.xml文件:
1
2
3
4
5
6
7
|
<?xml version= "1.0" encoding = "utf-8" ?>
<selector xmlns:android= "http://schemas.android.com/apk/res/android" >
<item android:drawable= "@drawable/textfield_activated_holo_dark" android:state_pressed= "true" />
<item android:drawable= "@drawable/textfield_activated_holo_dark" android:state_focused= "true" />
<item android:drawable= "@drawable/textfield_activated_holo_dark" android:state_selected= "true" />
<item android:drawable= "@drawable/textfield_default_holo_light" />
</selector>
|
3.在控件里引用
1
2
3
4
5
6
|
<edittext
android:id= "@+id/et_pwd"
android:layout_height= "35dp"
android:layout_margin= "10dp"
android:background= "@drawable/edittext_change"
android:inputtype= "textpassword" />
|
希望本文所述对大家android程序设计有所帮助。