Question

I'm trying to attach a layout to the bottom of every activity like so:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity" >

<include
    android:id="@+id/bottom_Menu"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    layout="@layout/bottom_menu" />


</RelativeLayout>

However, it doesn't put it at the bottom.

----EDIT-----

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_gravity="center" >

        <ToggleButton
            android:id="@+id/scheduleToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/SchedueToggle" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_gravity="center" >

        <ToggleButton
            android:id="@+id/exhibitorsToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/exhibitorsToggle" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_gravity="center" >

        <ToggleButton
            android:id="@+id/speakersToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/speakersToggle" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_gravity="center" >

        <ToggleButton
            android:id="@+id/MapsToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/MapsToggle" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_weight="1"
        android:gravity="center"
        android:layout_gravity="center" >

        <ToggleButton
            android:id="@+id/OtherToggle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/OtherToggle" />

    </LinearLayout>

</LinearLayout>
Was it helpful?

Solution

You don't need to wrap it in the layout, the include needs to have layout_width and layout_height specified for other layout_* fields to work. From the docs:

However, if you want to override layout attributes using the tag, you must override both android:layout_height and android:layout_width in order for other layout attributes to take effect.

So your updated layout:

<include
    android:id="@+id/bottom_Menu"
    android:layout_alignParentBottom="true"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/bottom_menu" />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top