当前位置: 移动技术网 > IT编程>移动开发>Android > Android2.3实现Android4.0风格EditText的方法

Android2.3实现Android4.0风格EditText的方法

2019年07月24日  | 移动技术网IT编程  | 我要评论

借我三千千万石,激战女神txt,请调申请

本文实例讲述了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文件:

<?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相关内容感兴趣的读者可查看本站专题:《android调试技巧与常见问题解决方法汇总》、《android开发入门与进阶教程》、《android多媒体操作技巧汇总(音频,视频,录音等)》、《android基本组件用法总结》、《android视图view技巧总结》、《android布局layout技巧总结》及《android控件用法总结

希望本文所述对大家android程序设计有所帮助。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网