I would like to have like a "toolbar" of different widgets at the bottom of my view... Each widget is componed of an ImageView
that represents the icon and a TextView
which is the description.
Here is the XML code :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linear_layout_shelves"
android:background="@drawable/final_shelves"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_marginLeft="70dp"
android:layout_marginRight="65dp"
android:layout_marginTop="@dimen/first_shelf_margin_top"
android:orientation="horizontal" >
<ImageView
android:id="@+id/image_11"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image1"
android:clickable="true"/>
<ImageView
android:id="@+id/image_12"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image2"
android:clickable="true" />
<ImageView
android:id="@+id/image_13"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_weight="1"
android:src="@drawable/image3"
android:clickable="true" />
</LinearLayout>
<!-- "Tools" : Cancel, delete, details -->
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
<!-- Cancel Widget -->
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/delete_widget"
android:layout_weight="1"
android:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel_icon"
android:src="@drawable/cancel_128"
android:clickable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cancel"
android:layout_above="@id/cancel_icon"
android:textColor="@color/white"
android:clickable="true" />
</RelativeLayout>
<!-- Delete Widget -->
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/cancel_widget"
android:layout_weight="1"
android:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/delete_icon"
android:src="@drawable/delete_blue_128"
android:clickable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Delete Card"
android:textColor="@color/white"
android:layout_below="@id/delete_icon"
android:clickable="true" />
</RelativeLayout>
<!-- Show details Widget -->
<RelativeLayout android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_details_widget"
android:layout_weight="1"
android:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/show_details_icon"
android:src="@drawable/info_128"
android:clickable="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show card details"
android:layout_below="@id/show_details_icon"
android:textColor="@color/white"
android:clickable="true" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
But my toolbar actually appears just in the bottom of the previous layout. Any idea how to fix the problem ?
Use RelativeLayout
for your outer layout. When you do, your inner views (in your case: LinearLayout) can have an attribute:
layout_alignParentBottom
Actually, your problem is already described here: How to align views at the bottom of the screen?