I am trying to set a selector for ImageView, but it does not work
My layout
<LinearLayout android:id="@+id/actionLayout" android:orientation="horizontal" android:background="@color/orange_color" android:gravity="center_vertical" android:paddingTop="@dimen/actions_top_bottom" android:paddingBottom="@dimen/actions_top_bottom" android:focusable="false" android:focusableInTouchMode="false" android:layout_width="fill_parent" android:layout_height="wrap_content"> <ImageButton android:layout_width="wrap_content" android:layout_height="@dimen/actions_height" android:id="@+id/btnNoRecord" android:scaleType="centerInside" android:src="@drawable/ic_action_record" android:onClick="onRecordSwitcherClick" android:layout_weight="1" android:background="@drawable/selector"/> ... </LinearLayout>
My selector.xml
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_pressed="true"> <shape android:shape="rectangle"> <solid android:color="@color/dark_orange_color"/> </shape> </item> <item> <shape android:shape="rectangle"> <solid android:color="@color/orange_color"/> </shape> </item> </selector>
Where is the mistake? Maybe there is something in the properties of LinearLayout?
EDIT I just found that ImageButton outside LinearLayout is working fine. But I really need a layout.
source share