gpt4 book ai didi

android - 如何在另一个布局下部分获取布局

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

<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:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawerLayout"
tools:context=".MainActivity">

<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="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:elevation="0dp">

<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|enterAlways"/>

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/toolbar2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|enterAlways">


<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:background="@color/colorAccent"/>


</com.google.android.material.appbar.CollapsingToolbarLayout>

</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="-80dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>


<com.google.android.material.navigation.NavigationView
android:id="@+id/navigationView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="@layout/drawer_header"
app:menu="@menu/menu_drawer"
/>
框架布局包含我的回收器 View ..
我为线性布局添加了一个折叠工具栏布局
我试图让框架布局到折叠工具栏布局的一半
但这是我得到的结果
enter image description here
我想要的是..
enter image description here
如果您有更好的方法来做到这一点,请随时提供帮助。我是一个完整的菜鸟..
我很抱歉我在绘画图像方面缺乏艺术专业知识......
请检查下面的答案以获取解决方案如果您有同样的问题..我已经使用相同的方法解决了我的问题

最佳答案

在您的 FrameLayout 中添加这些属性

            app:layout_anchor="@id/app_bar"
app:behavior_overlapTop="45dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_anchorGravity="bottom"
编辑:
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/contentView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">


<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorSurface">

<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
app:layout_scrollFlags="scroll|exitUntilCollapsed">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/placeholder_200_dp"
android:background="@color/red"/>

</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>


<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchor="@id/app_bar"
app:behavior_overlapTop="45dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvAttendanceHistory"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_anchorGravity="bottom"
android:layout_marginStart="@dimen/margin_medium"
android:layout_marginEnd="@dimen/margin_medium"
android:background="@drawable/card_white_design"
tools:listitem="@layout/item_student_attendance" />
</FrameLayout>

</androidx.coordinatorlayout.widget.CoordinatorLayout>
上述布局将使我的 FrameLayout 重叠 45dp
recyclerView with overlap

关于android - 如何在另一个布局下部分获取布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63114835/

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