Reputation: 2038
I'm not able to make a View
that fill the height of a RelativeLayout
, which is the layout of ListView
items. Here is my layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<View
android:id="@+id/fill_the_height_please"
android:layout_width="15dp"
android:layout_height="match_parent"
android:background="@color/red"/>
<TextView
android:id="@+id/delivery_list_item_dest"
android:layout_width="wrap_content"
android:layout_toRightOf="@id/fill_the_height_please"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="2dp"
android:text="Destinatario" />
<TextView
android:id="@+id/delivery_list_item_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@id/delivery_list_item_dest"
android:layout_below="@id/delivery_list_item_dest"
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:text="Location" />
<ImageButton
android:id="@+id/delivery_list_item_mapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="0dp"
android:src="@drawable/map_location"
android:background="@null" />
View with id fill_the_height_please not fill the item height. In figure below you can see the result (nothing is shown):
I'd like something like this:
ù
I have also try to change view layout as follows but not works anyway:
<View
android:id="@+id/fill_the_height_please"
android:layout_width="15dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:background="@color/red"/>
Please can you help to achieve my goal? Thank you.
Upvotes: 0
Views: 1312
Reputation: 2038
Looking here it seems RelativeLayout
has a bug in version 17 and lower. So i have change my layout as follows:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<View
android:id="@+id/fill_the_height_please"
android:layout_width="15dp"
android:layout_height="match_parent"
android:background="@color/red"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical" >
<TextView
android:id="@+id/delivery_list_item_dest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Destinatario"
android:layout_marginBottom="5dp" />
<TextView
android:id="@+id/delivery_list_item_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Location" />
</LinearLayout>
<ImageButton
android:id="@+id/delivery_list_item_mapBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="0dp"
android:src="@drawable/map_location"
android:background="@null" />
</RelativeLayout>
A little bit more complex but works. However i leave the question unresolved in case someone find a solution using only a RelativeLayout
Upvotes: 1
Reputation: 1494
Try changing
android:layout_toRightOf="@id/delivery_list_item_statusBtn"
to
android:layout_toRightOf="@id/fill_the_height_please"
You don't have delivery_list_item_statusBtn. But i see red part even without changing this. Try it and if it doesn't help please post code of your adapter.
Upvotes: 1
Reputation: 820
One suggestion would be add layout_alignTop="@+id/delivery_list_item_mapBtn" and layout_alignBottom="@+id/delivery_list_item_mapBtn" to the View and make it always fit the image height.
Upvotes: 2