Android:相对布局选择器不';行不通
我使用带有选择器资源xml的相对布局来突出显示单击时的相对布局。但它不会在单击时突出显示相对布局。下面我放置了相应的选择器xml、布局xml和可绘制的xml 布局代码段:Android:相对布局选择器不';行不通,android,android-layout,android-relativelayout,android-selector,Android,Android Layout,Android Relativelayout,Android Selector,我使用带有选择器资源xml的相对布局来突出显示单击时的相对布局。但它不会在单击时突出显示相对布局。下面我放置了相应的选择器xml、布局xml和可绘制的xml 布局代码段: <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout
<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_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_pressed="true"/>
<!-- Default -->
<item android:drawable="@drawable/icon_default" />
请注意,在原始选择器中,两种状态下的Drawable都相同。将此选项用于选择器:
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_pressed="true"/>
<!-- Default -->
<item android:drawable="@drawable/icon_default" />
请注意,在原始选择器中,两种状态下的Drawable都相同。将此选项用于选择器:
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_pressed="true"/>
<!-- Default -->
<item android:drawable="@drawable/icon_default" />
请注意,在原始选择器中,两种状态下的Drawable都相同。将此选项用于选择器:
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_pressed="true"/>
<!-- Default -->
<item android:drawable="@drawable/icon_default" />
请注意,在原始选择器中,两种状态下的drawable都相同。使用此代码并从drawable中获取不同的图像
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_focused="true" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_focused="false" android:state_selected="true"/>
<!-- When not selected -->
<item android:drawable="@drawable/icon_default"/>
使用此代码并从drawable拍摄不同的图像
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_focused="true" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_focused="false" android:state_selected="true"/>
<!-- When not selected -->
<item android:drawable="@drawable/icon_default"/>
使用此代码并从drawable拍摄不同的图像
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_focused="true" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_focused="false" android:state_selected="true"/>
<!-- When not selected -->
<item android:drawable="@drawable/icon_default"/>
使用此代码并从drawable拍摄不同的图像
<!-- Selected -->
<item android:drawable="@drawable/icon_selected" android:state_focused="true" android:state_selected="true"/>
<!-- Pressed -->
<item android:drawable="@drawable/icon_pressed" android:state_focused="false" android:state_selected="true"/>
<!-- When not selected -->
<item android:drawable="@drawable/icon_default"/>
还可以在选择器中添加类似于android:state\u pressed=“true”
的状态,然后try您可以在所选或按中拍摄相同的图像,还可以在选择器中添加类似于android:state\u pressed=“true”的状态,然后try您可以在所选或按中拍摄相同的图像,还可以添加类似于android:state\u pressed=“true”的状态
在选择器和try中,您可以在选定或按下的状态下拍摄相同的图像,也可以在选择器和try中添加类似于android:state_pressed=“true”
的状态,您可以在选定或按下的状态下拍摄相同的图像