gpt4 book ai didi

Android RelativeLayout 选择器 state_pressed 不起作用

转载 作者:IT老高 更新时间:2023-10-28 23:37:59 26 4
gpt4 key购买 nike

我有这样的 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>

enter image description here

看起来像:

enter image description here

我的 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 张图片:默认情况下,选中并按下。

但我有一个问题:只有默认和 state_selected 图像可以按预期工作,但 state_pressed 似乎不起作用。

我有几个上面提到的RelativeLayouts,没有人使用state_pressed

有人知道我的问题在哪里吗?

谢谢!

最佳答案

确保您的 RelativeLayout 是可点击的

关于Android RelativeLayout 选择器 state_pressed 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16164128/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com