android - 如何在 kotlin 中实现折叠工具栏
问题描述
我有一个带有折叠工具栏的 XML 代码,当我单击尝试实现嵌套滚动条时,整个 xml 的对齐方式会发生变化。我尝试了很多方法。
<?xml version="1.0" encoding="utf-8"?>
<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/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.RestaurantMenuActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:elevation="0dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolMenuBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/red"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark" />
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_marginTop="50dp"
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
>
<ImageView
android:id="@+id/rest_image"
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/restaurant_image"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<RelativeLayout
android:layout_marginTop="250dp"
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerViewRestaurantMenu"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp" />
<RelativeLayout
android:id="@+id/relativeLayoutProceedToCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:visibility="invisible">
<Button
android:id="@+id/btnProceedToCart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="@color/white"
android:text="proceed_to_cart_btn"
android:textColor="@color/white" />
</RelativeLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/progressMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<ProgressBar
android:theme="@style/CircularProgress"
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
我通过安排它尝试了很多次,但是一旦我为相对布局(id:frameLayout)引入嵌套滚动视图,整个视图就会崩溃。
解决方案
推荐阅读
- c# - 从 servicenow 公开的 SOAP 的 NULL 响应以获取事件编号详细信息?
- git - 由于冲突解决不当,将分支重新合并到主分支
- javascript - 如何在 google 和 API 的操作中使用 async 和 await
- pyspark - IllegalArgumentException:'字段“标签”不存在。在 PYSPARK
- django - 我有 django rest_framework ListAPIView 方法,它返回用户列表,我如何从同一个用户列表中排除请求用户
- orchardcms - 覆盖 Orchard 中的密码格式
- polymer - Polymer 3 - KeyframeEffect 未定义
- ios - 渐变 UIButton 的边框与圆角半径
- sql - 从聚集复合键移动到顺序整数聚集键时性能损失
- bing-maps - 在 Bing 地图上执行反向英国邮政编码查找