Android 如何给LinearLayout(或其他视图)设置可点击和可聚焦
Android How to LinearLayout (or other views) set clickable and focusable
我想为 LinearLayout 设置可聚焦和可点击模式(如上图所示)。我该怎么做?
在您定义的 XML 文件中,您可以在元素中包含:
android:focusable="true"
或
android:可点击="true"
试试这个,它对我有用
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground">
</LinearLayout>
我想为 LinearLayout 设置可聚焦和可点击模式(如上图所示)。我该怎么做?
在您定义的 XML 文件中,您可以在元素中包含:
android:focusable="true"
或
android:可点击="true"
试试这个,它对我有用
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:clickable="true"
android:focusable="true"
android:background="?android:attr/selectableItemBackground">
</LinearLayout>