android - NestedScrollview 不适用于 Drawerlayout
问题描述
我正在尝试在我的抽屉布局中添加嵌套滚动视图,但嵌套滚动视图不起作用,即我的视图没有向下滚动。我的内容主要布局应该是滚动布局。我的布局包含工具栏的线性布局和主屏幕的主要内容和导航视图。任何类型的帮助将不胜感激。这是我的 XML 文件代码:
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activities.MainActivity">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical">
<include
layout="@layout/drawer_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<include
layout="@layout/content_main"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.navigation.NavigationView
android:id="@+id/navigation_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/drawer_menu">
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
解决方案
将 NestedScrollView 高度设置为 match_parent
推荐阅读
- delphi - Delphi/DevExpress 在复选框状态下同步主/详细信息
- build - windowsdriver.common.targets 丢失
- wpf - 在 DataTemplate 中格式化货币
- javascript - 如何在 Puppeteer 上跟踪弹出模式
- reactjs - 盖茨比:为什么 a.png 工作,但 b.png 返回错误:模块系统需要 emitFile?
- twitter-bootstrap - 我无法将 Bootstrap 添加到我的 rails 应用程序
- reactjs - 更改状态时更改具有 id 的状态的克隆
- python - 从 google colab 访问 google 驱动程序 - 失败(“意外错误响应:
- excel - 创建具有 2 个条件的查找公式 - 匹配 ID 和特定范围内的日期
- ruby-on-rails - 如何找到相同的记录并为每个导轨执行操作