<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:focusableInTouchMode="true"
android:orientation="vertical" >
这个属性的意思很明显,就是可以通过touch来获得focus。在手机上开发用的不多,因为大多手机都是触摸式的。
但是有可能在TV上的应用需要用到:
一个界面上有一个自定义个button,我需要进入这个界面就高亮这个button。但是用遥控选择这个程序进入能正常显示,用鼠标点击进入就没有高亮的效果。最后添加上这个属性,效果出来了。
可见,click事件和touch事件在焦点处理上是不同的。