首页 > 代码库 > LinearLayout按下(pressed)或获取焦点(focused)时背景设置不同颜色或图片

LinearLayout按下(pressed)或获取焦点(focused)时背景设置不同颜色或图片

 1 <LinearLayout    2     xmlns:android="http://schemas.android.com/apk/res/android"   3     android:id="@+id/myview"   4     android:orientation="horizontal"   5     android:layout_width="fill_parent"   6     android:layout_height="wrap_content"   7     android:gravity="top"   8     android:background="@drawable/myDrawable"   9     android:clickable="true" >  10 </LinearLayout>

加上 android:clickable="true" 就可以了

LinearLayout按下(pressed)或获取焦点(focused)时背景设置不同颜色或图片