我想要有一個回收器視圖行作爲給定的數字。基本上,圖像視圖將具有固定的尺寸。這兩個文本視圖應該覆蓋整個空間,但不應將圖像視圖移出屏幕。它也不應該裁剪它。 請忽略填充和邊距。除了圖像視圖和兩個文本視圖之間會有一個邊距。如何設置此視圖?
我曾嘗試:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.8">
<TextView
android:id="@+id/tv1"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:layout_alignParentStart="true"
android:layout_below="@id/tv1"
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="2"
android:ellipsize="end"/>
</RelativeLayout>
<ImageView
android:id="@+id/img"
android:layout_weight="0.2"
android:layout_width="85dp"
android:layout_height="50dp"
android:layout_marginStart="12dp"
android:layout_centerVertical="true"
android:scaleType="centerCrop"/>
</LinearLayout>
這樣做的問題是,與在textviews文本圖像視圖改變尺寸。我不要那個。我希望維度得到修復。
我本來可以把整個事情放在一個相對佈局中,但是我無法在兩個文本視圖和圖像視圖之間保留一個邊距。
這可以爲不同的屏幕尺寸創建問題嗎? –
@ArkaPravaBasu它可以,但在這種情況下,你將不得不添加額外的XML文件來定義根據不同的屏幕尺寸調整大小。 – Andrei
那麼有什麼方法可以避免大小分配? –