對於RecyleView
的每個項目,我正在使用android:layout_alignParentBottom
作爲向下箭頭ImageView
的內部RelativeLayout
。
但它只適用於Preview
模式,當我運行應用程序它不起作用。我不知道爲什麼會發生這種情況。
我在截圖說明更多關於我的問題android:layout_alignParentBottom在運行時不起作用
<android.support.v7.widget.CardView
android:id="@+id/cv"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/item_layoutStart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#E8F5E9"
android:orientation="vertical">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_gravity="center_vertical|right"
android:clickable="true"
android:scaleType="fitCenter"
android:src="@mipmap/ic_launcher" />
<TextView
android:id="@+id/item_tvRepeatTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="10" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff0"
android:layout_alignTop="@id/item_layoutStart"
android:layout_alignBottom="@id/item_layoutStart"
android:orientation="vertical"
android:layout_toRightOf="@id/item_layoutStart">
<TextView
android:id="@+id/item_tvTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="aa aa aaaaaa aa aa aaaaaa aa aa aaaaaa " />
<TextView
android:id="@+id/item_tvResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/item_tvTitle"
android:text="aa aa aaaaaa aa aa aaaaaa aa aa aaaaaa" />
<ImageView android:id="@+id/item_ivExpand"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:padding="3dp"
android:src="@drawable/selector_arrow_down"/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
UPDATE 如果我解決我的RelativeLayout
通過具體的值高度,android:layout_alignParentBottom
工作
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
>
但對我來說,我想RelativeLayout
高度等於LinearLayout
<RelativeLayout
android:layout_alignTop="@id/item_layoutStart"
android:layout_alignBottom="@id/item_layoutStart"
>
android:layout_alignParentBottom
不行
任何幫助將是巨大的aprreciated
用android:layout_gravity =「right | bottom」替換以下行:android:layout_gravity =「right」in item_ivExpand。 –
將'ImageView'的父親'RelativeLayout'的'layout_height'改爲'match_parent'。 –
@SagarTrehan謝謝,但它不起作用。我的問題仍然發生在 –