在android中实现自定义Edittext样式

时间:2015-05-12 04:33:20

标签: android android-layout

我在android中通过在drawable res中添加xml来创建自定义编辑文本。如下所示

==

所以我只想将edittext作为一行。 但是,当我实现这一点时,几秒钟后,edittext的上边框可见,然后它就消失了...... 我真的不明白为什么会这样......

1 个答案:

答案 0 :(得分:1)

创建res / drawable / custom_edittext_style.xml

space

将所有需要的可绘制文件添加到drawable文件夹中。

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true" android:drawable="@drawable/apptheme_textfield_default_holo_light" />
<item android:state_window_focused="false" android:state_enabled="false" android:drawable="@drawable/apptheme_textfield_disabled_holo_light" />
<item android:state_enabled="true" android:state_focused="true" android:drawable="@drawable/apptheme_textfield_activated_holo_light" />
<item android:state_enabled="true" android:state_activated="true" android:drawable="@drawable/apptheme_textfield_focused_holo_light" />
<item android:state_enabled="true" android:drawable="@drawable/apptheme_textfield_default_holo_light" />
<item android:state_focused="true" android:drawable="@drawable/apptheme_textfield_disabled_focused_holo_light" />
<item android:drawable="@drawable/apptheme_textfield_disabled_holo_light" />