LinearLayout , RelativeLayout没有按下效果
可能以前写代码都没有注意过这个小问题,
今天碰到了,给LinearLayout或者RelativeLayout设置一个有按下效果的backgroud,如果LinearLayout,RelativeLayout布局下面有可以抢走焦点的View的话,这个按下效果就会不起作用
<LinearLayout
android:id="@+id/ll_sd"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/play_sd_selector"
android:gravity="center"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon_play" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:text="@string/play_sd"
android:textColor="@color/white"
android:textSize="@dimen/sp_common" />
</LinearLayout>
解决办法:给LinearLayout或者RelativeLayout加上
android:clickable="true"
android:focusable="true"
浙公网安备 33010602011771号