用于键盘和鼠标焦点的Android状态

时间:2018-02-15 08:10:12

标签: android

对于edittext composer show tendoo/cms是指键盘焦点还是触摸焦点?

我正面临这个问题,我有一个edittext。我想申请

  

键盘对焦和触控的不同背景可绘制和颜色   对焦。

还有什么区别是state_pressed和state_focused?

1 个答案:

答案 0 :(得分:0)

  

对于edittext android:state_focused表示键盘焦点或触摸   聚焦?

这意味着,您的edittext是专注的。 (光标将在该edittext中)即使您没有触摸edittext,但光标位于该edittext中,它也会被聚焦。

如果要为不同的状态应用不同的背景,可以使用

<selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:state_pressed="true" android:drawable="@drawable/yourdrawable1" />
  <item android:state_enabled="true" android:drawable="@drawable/drawable2" />
  <item android:state_focused="true" android:drawable="@drawable/drawable3" />
  <item android:drawable="@drawable/draw" />
</selector>

下面,

state_pressed - &gt;触摸编辑文本时(ACTION_DOWN)

您可以组合这些状态以添加更多自定义背景。例如:

<item android:state_pressed="true" android:state_enabled="true" android:drawable="@drawable/yourdrawable"/>
<item android:state_pressed="true" android:state_enabled="false" android:drawable="@drawable/yourdrawable"/>