I’m used to the fact that items of listview without any problem (even with complicated layout) handle onpress events (some actions that makes it pressed and unpressed). But now I want the same from LinearLayout – if you press anyway on layout, all descendants should get onpress events.
This is the part of my fragment layout, which should be highlighted onpress event.
<LinearLayout
android:id="@+id/ll_about_fragment_feedback"
android:gravity="center_vertical"
android:layout_height="54dp"
android:background="@drawable/about_item_bkg"
android:layout_width="match_parent">
<ImageView
android:layout_height="wrap_content"
android:background="@drawable/about_item_feedback_icon"
android:layout_width="wrap_content"
android:layout_marginLeft="11dp"/>
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="@string/about_fragment_feedback"
android:layout_marginLeft="14dp"
android:textSize="16dp"
android:textColor="@drawable/about_item_textcolor"/>
</LinearLayout>
Background of root layout changes onpress, but textcolor of descendants don’t. Looks like they don’t get event from root.
So, can you help?
UPDATE: LinearLayout ll_about_fragment_feedback has bound OnClickListener and there is everything fine with selecrors
If you want a
Selectorto apply to all views under yourLinearLayoutthen you just need to addandroid:duplicateParentState="true"to all of the child views.