XML 属性用法“android:focusableInTouchMode" [英] XML attribute usage "android:focusableInTouchMode"

查看:37
本文介绍了XML 属性用法“android:focusableInTouchMode"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我为什么使用以下 XML 属性?我在 developer.android.com 上查找了文档,但什么也看不懂.

Please tell me why is the following XML attribute used ? I looked up the documentation on developer.android.com but could not understand anything.

android:focusableInTouchMode

推荐答案

这篇博文可以帮助您理解触摸模式的含义.

This blog post can help you to understand the meaning of touch mode.

最相关的部分:

触摸模式是视图层次结构的一种状态,它完全取决于用户与手机的交互.就其本身而言,触摸模式很容易理解,因为它只是表明上次用户交互是否是通过触摸屏执行的.例如,如果您使用的是 G1 手机,选择带有轨迹球的小部件将使您脱离触摸模式;但是,如果您用手指触摸屏幕上的按钮,您将进入触摸模式.当用户不处于触摸模式时,我们谈论的是轨迹球模式、导航模式或键盘导航,因此如果您遇到这些术语,请不要感到惊讶.最后,与触摸模式直接相关的 API 只有一个,View.isInTouchMode().

The touch mode is a state of the view hierarchy that depends solely on the user interaction with the phone. By itself, the touch mode is something very easy to understand as it simply indicates whether the last user interaction was performed with the touch screen. For example, if you are using a G1 phone, selecting a widget with the trackball will take you out of touch mode; however, if you touch a button on the screen with your finger, you will enter touch mode. When the user is not in touch mode, we talk about the trackball mode, navigation mode or keyboard navigation, so do not be surprised if you encounter these terms. Finally, there is only one API directly related to touch mode, View.isInTouchMode().

所以 android:focusableInTouchMode="true" 意味着当手机处于触摸模式时,视图可以获得焦点.

So android:focusableInTouchMode="true" means that the view can get the focus when the phone is in touch mode.

通常,EditText 在触摸模式下通常是可聚焦的,而另一方面,Button 在触摸模式下通常不可聚焦.

Typically an EditText is generally focusable in touch mode and on the other hand a Button is generally not focusable in touch mode.

这篇关于XML 属性用法“android:focusableInTouchMode"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆