I have a TextView
and ImageView
in a ListView
row, positioned next to each other. However, the ImageView
doesn't show up at all, and doesn't register clicks either. This is the XML code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView"
android:text="text"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_centerVertical="true"
android:padding="10dp" />
<ImageView
android:id="@+id/imageView"
android:clickable="true"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_centerVertical="true"
android:layout_toRightOf="@id/textView"
android:src="@drawable/ic_action"/>
</RelativeLayout>
The problem seems to lie in the layout_toRightOf
line, if I remove it, the ImageView
is shown, but in the wrong place. But I don't understand why it's causing a problem. What am I missing?