Support Toolbar's custom view not using full width
Asked Answered
M

1

7

I'm using support v7's toolbar. I added a custom view, but the custom view doesn't seem to obey "match_parent". It would only stretch as far as the first icon it sees. Does anyone know a fix to this? Or is the toolbar not meant to be used this way?

enter image description here

My code:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    tools:context="com.example.activities.ToolbarActivity"
    >

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="100dp"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/light_gray"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        android:gravity="bottom"
        android:clipChildren="false"
        >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:background="@color/green"
            >


        </RelativeLayout>

    </android.support.v7.widget.Toolbar>

</FrameLayout>
Mercy answered 19/11, 2014 at 2:36 Comment(1)
Are you simply trying to do what is done in this question. #26849343Shopkeeper
R
1

I have succeed with the approach in Simon's link:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:clipChildren="false"
    tools:context="com.example.activities.ToolbarActivity">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_height="100dp"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/light_gray"
        app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
        app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginTop="70dp"
        android:background="@color/green">

    </RelativeLayout>

</RelativeLayout>
Rupe answered 13/3, 2015 at 21:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.