我有一個TextView
和ImageView
在ListView
行,彼此相鄰。但是,ImageView
根本沒有顯示,也沒有註冊點擊。這是XML代碼:Android:TextView旁邊的ImageView沒有顯示
<?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>
的問題似乎在於在layout_toRightOf
行,如果我刪除它時,ImageView
顯示,但在錯誤的地方。但我不明白爲什麼它會造成問題。我錯過了什麼?
嘗試使用線性佈局與水平方向 – Deepesh
@Technicolor似乎'的android:layout_width = 「320dp」'太很多爲你的屏幕爲什麼你完全需要320 DP? –