gpt4 book ai didi

toolbar - 支持工具栏的自定义 View 不使用全宽

转载 作者:行者123 更新时间:2023-12-04 08:52:06 25 4
gpt4 key购买 nike

我正在使用 support v7 的工具栏。我添加了一个自定义 View ,但自定义 View 似乎不服从“match_parent”。它只会延伸到它看到的第一个图标。有谁知道解决这个问题?或者工具栏不打算以这种方式使用?

enter image description here

我的代码:

<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>

最佳答案

我在 Simon 的链接中的方法取得了成功:

<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>

关于toolbar - 支持工具栏的自定义 View 不使用全宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27007985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com