简体   繁体   中英

Android How to LinearLayout (or other views) set clickable and focusable

像这样

I want to set focusable and clickable mode for LinearLayout (like in above image). How to I make this?

try this, it worked for me

<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>

In the XML file that you defined, you can have in your element:

android:focusable="true"

or

android:clickable="true"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM