- 时间:2020-02-03 00:05 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:Android2.3实现Android4.0风格EditText的方法
本文实例讲述了Android2.3实现Android4.0风格EditText的方法。分享给大家供大家参考,具体如下:
效果如下:
[img]http://files.jb51.net/file_images/article/201603/2016310112300749.png?2016210112313[/img]
思路:在源码里找到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:[img]http://files.jb51.net/file_images/article/201603/2016310112641174.png?2016210112656[/img]
textfield_multiline_activated_holo_dark.9.png:[img]http://files.jb51.net/file_images/article/201603/2016310112708125.png?2016210112729[/img]
2.
在drawable文件夹下建立edittext_change.xml文件:
<?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.在控件里引用
<EditText
android:id="@+id/et_pwd"
android:layout_height="35dp"
android:layout_margin="10dp"
android:background="@drawable/edittext_change"
android:inputType="textPassword" />
更多关于Android相关内容感兴趣的读者可查看本站专题:《[url=http://www.1sucai.cn/Special/508.htm]Android调试技巧与常见问题解决方法汇总[/url]》、《[url=http://www.1sucai.cn/Special/410.htm]Android开发入门与进阶教程[/url]》、《[url=http://www.1sucai.cn/Special/398.htm]Android多媒体操作技巧汇总(音频,视频,录音等)[/url]》、《[url=http://www.1sucai.cn/Special/381.htm]Android基本组件用法总结[/url]》、《[url=http://www.1sucai.cn/Special/375.htm]Android视图View技巧总结[/url]》、《[url=http://www.1sucai.cn/Special/371.htm]Android布局layout技巧总结[/url]》及《[url=http://www.1sucai.cn/Special/124.htm]Android控件用法总结[/url]》
希望本文所述对大家Android程序设计有所帮助。