У меня 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 изображения: по умолчанию выбрано и нажато.
Но у меня есть проблема: только по умолчанию и state_selected
изображения работают, как ожидалось, но state_pressed
dosn't, похоже, работает.
У меня есть несколько вышеупомянутых RelativeLayouts
, и никто не работает с state_pressed
.
Кто-нибудь знает, где моя проблема?
Спасибо!