【发布时间】:2014-04-18 10:35:17
【问题描述】:
我正在使用带有选择器资源 xml 的相对布局来突出显示点击时的相对布局。但它不会突出显示点击时的相对布局。下面我放了相应的选择器xml、布局xml和drawable。
布局代码片段:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:id="@+id/rlShare"
android:background="@drawable/icon_selector"
android:clickable="true">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerInParent="true"
android:contentDescription="@string/cd_new_exam"
android:scaleType="fitXY"
android:src="@drawable/share_icon" />
</RelativeLayout>
选择器 xml 文件:
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_focused="true" android:state_selected="false"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_selected" android:state_focused="false" android:state_selected="true"/>
请帮帮我,
提前谢谢你。
【问题讨论】:
-
还在选择器中添加
android:state_pressed="true"之类的状态并尝试 -
您可以在选中或按下时拍摄相同的图像
标签: android android-layout android-relativelayout android-selector