为了账号安全,请及时绑定邮箱和手机立即绑定

尝试将导航抽屉按钮添加到应用程序栏

尝试将导航抽屉按钮添加到应用程序栏

qq_笑_17 2021-06-11 17:26:35
我正在关注本教程我被困在我试图将按钮添加到应用程序栏的地方。当我向右滑动时,会出现导航抽屉,因此可以正常工作。它只是我遇到问题的栏中的按钮,当我将其添加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它位于它的顶部。我哪里错了?
查看完整描述

2 回答

?
翻阅古今

TA贡献1780条经验 获得超5个赞

放在NavigationView下面FrameLayout


查看完整回答
反对 回复 2021-06-17
  • 2 回答
  • 0 关注
  • 127 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信