Android RelativeLayout选择器state_pressed不起作用 [英] Android RelativeLayout Selector state_pressed doesn't work
本文介绍了Android RelativeLayout选择器state_pressed不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的RelativeLayout
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/contacts"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_weight="0.2"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:contentDescription="@string/content_description_contacts"
android:scaleType="fitXY"
android:src="@drawable/contacts" />
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="@id/image"
android:paddingBottom="10dp"
android:textColor="@drawable/text_color"
android:text="@string/button_contacts"
android:textSize="12sp" />
</RelativeLayout>
,看起来像:
我的contacts
选择器似乎是:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/contacts_over" />
<item android:state_selected="true"
android:drawable="@drawable/contacts_selected" />
<item
android:drawable="@drawable/contacts_default" />
</selector>
如您所见,我有3张图像:默认情况下,已选择并按下.
As you can see I have 3 images: by default, selected and pressed.
但是我有一个问题:只有默认图像和state_selected
图像可以正常工作,但是state_pressed
似乎不起作用.
But I have a problem: only default and state_selected
images are work as expected, but state_pressed
dosn't seem to work.
我有几个上面提到的RelativeLayouts
,没有人使用state_pressed
.
I have several above mentioned RelativeLayouts
and no one works with state_pressed
.
有人知道我的问题在哪里吗?
Does anybody know where is my problem?
谢谢!
推荐答案
确保您的RelativeLayout可点击
make sure your RelativeLayout is clickable
这篇关于Android RelativeLayout选择器state_pressed不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文