我試圖用比率爲20%和80%的兩個主要元素創建項目佈局到RecyclerView。第一個元素是ImageView,第二個元素是帶有一些TextView的LinearLayout。基本上,它應該是這樣的:LinearLayout內部的ImageView - 錯誤的比例
20% 80%
+-----+-------------------+
| Img | Author, Date |
+-----+ Title... |
| |
+-------------------------+
所以,我創建瞭如下的佈局,但圖像總是大於20%。
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:src="@drawable/image" />
<LinearLayout
android:layout_width="0dp"
android:layout_weight="4"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
我想要的layout_width
每一個組合,但總是一些錯誤的比率。
任何幫助將不勝感激。
機器人:weightSum = 「5」 主要佈局 – Pavya
@Pravin遺憾的是,即使weightSum ImageView的太大。 – rubin94