我在片段中有两个recyclerviews,一个是水平的,第二个是垂直的,当我滚动卧式螺线管时不会滚动,但是垂直滚动..我想同时在我的工具栏下垂直滚动并且我希望我的工具栏折叠问题是什么 ?
这是我的主要活动
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#242a38"
android:fitsSystemWindows="true"
tools:context=".ui.HomeActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<com.ismaeldivita.chipnavigation.ChipNavigationBar
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="72dp"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true"
android:layout_marginBottom="0dp"
android:background="@drawable/round"
android:elevation="16dp"
android:padding="8dp"
app:cnb_menuResource="@menu/bottom_navigation_menu" />
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#242a38"
android:fitsSystemWindows="true"
android:foregroundGravity="top"
app:headerLayout="@layout/nav_header"
app:itemIconTint="#FFFFFF"
app:itemTextColor="#FFFFFF"
app:menu="@menu/drawer_menu">
</com.google.android.material.navigation.NavigationView>
</androidx.drawerlayout.widget.DrawerLayout>
我的家庭片段
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#242a38"
tools:context=".ui.HomeFragment">
<include layout="@layout/app_bar_home" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/myrecycler"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="11dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView10" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/posts_recycler"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginTop="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/myrecycler" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
答案 0 :(得分:1)
您应该使用NestedScrollView并将所有Vertical和Horizontal RecyclerViews放置在此处。将nestedScrolling行为添加到您的RecyclerViews。
答案 1 :(得分:0)
您可以使用XML或以编程方式指定reycler的布局:
XML:
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
/>
代码:
LinearLayoutManager layoutManager
= new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
RecyclerView myList = (RecyclerView) findViewById(R.id.my_recycler_view);
myList.setLayoutManager(layoutManager);