支持工具栏的自定义视图未使用全角

问题描述 投票:8回答:1

我正在使用支持v7的工具栏。我添加了一个自定义视图,但是该自定义视图似乎没有遵循“ match_parent”。它只会延伸到看到的第一个图标。有人知道解决办法吗?还是不打算以这种方式使用工具栏?

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLnN0YWNrLmltZ3VyLmNvbS9NWEhySC5wbmcifQ==” alt =“在此处输入图像描述”>

我的代码:

<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>
toolbar android-appcompat
1个回答
1
投票

我在西蒙链接中的方法已经成功:

<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>
© www.soinside.com 2019 - 2024. All rights reserved.