gpt4 book ai didi

java - 尝试将抽屉导航按钮添加到应用栏

转载 作者:行者123 更新时间:2023-12-02 02:00:56 26 4
gpt4 key购买 nike

我正在关注this tutorial

我被困在尝试将按钮添加到应用栏的地方。

当我向右滑动时,抽屉导航就会出现,这样就可以工作了。它只是我遇到问题的栏中的按钮,当我将 v7.widget.Toolbar 添加到 FrameLayout 下的 XML 中时,它会破坏布局。

最初,在我的 XML 中,我只有一个约束布局,其中一个 Scrollview 作为子项,其内部有一个 LinearView(垂直)。

但是我无法理解为什么这不起作用:

<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">


<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_view"
app:headerLayout="@layout/nav_header" />

<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >


<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">



<LinearLayout
android:id="@+id/seeds_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="16dp"
android:background="@drawable/customborder"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"></LinearLayout>
</ScrollView>

</FrameLayout>

当我运行此命令时,顶部栏似乎占据了整个窗口,并且颜色消失,并且按钮不可单击,因为 LinearLayout 位于其顶部。我哪里出错了?

最佳答案

NavigationView放在FrameLayout下面。

关于java - 尝试将抽屉导航按钮添加到应用栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51590194/

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