我知道如何将onClick侦听器添加到LinearLayout以使整个布局成为单击目标,但我希望在点击时突出显示LinearLayout,就像列表视图中的列表项一样。做这件事最好的方法是什么?
发布于 2014-09-05 20:51:44
我更喜欢一种简单的方式:
<LinearLayout android:orientation="vertical"
android:id="@+id/layoutIdentifier"
android:clickable="true"
android:background="?android:attr/selectableItemBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- put views here -->
</LinearLayout>您不能以这种方式更改按下状态的背景,但有时您并不真正需要这样做。
https://stackoverflow.com/questions/5821044
复制相似问题