我BottomSheet使用这种DialogFragment方法实现了.我有一个TabLayout和ViewPager在BottomSheet.该ViewPager托管2页,每一个膨胀RecyclerView.第一个(咖啡标签)RecyclerView滚动很好.我现在遇到的问题是,对于第二个(Milk选项卡),滚动不起作用.知道我该如何解决这个问题?谢谢!
您可以使用我在这里创建的演示项目进行测试:https:// github.com/choongyouqi/ bottomsheet`
我在LinearLayout中有一个带有BottomSheetBehavior的两个RecyclerView.当您单击第一个RecyclerView内的项目(带网格)时,RecyclerView将设置为Gone,并显示第二个RecyclerView(带有列表).当显示第二个Recycler时,您无法上下滑动BottomSheet而不是List即使在Expanded State中也在滚动.如果First Recycler已经上市,一切都很好.有没有办法让BottomSheet再次上下滑动?
<LinearLayout
android:id="@+id/sliding_layout_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="400dp"
app:layout_behavior="@string/bottomSheetBehavior">
<android.support.v7.widget.RecyclerView
android:id="@+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:background="@color/white"
android:clickable="true"
android:scrollbars="none" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="@dimen/activity_horizontal_margin"
android:layout_marginStart="@dimen/activity_horizontal_margin"
android:background="@color/white"
android:clickable="true"
android:scrollbars="none" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
GridAdapter:
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
String categorieName = mCategories.get(position);
final CategoryFilterEvent event = new CategoryFilterEvent(categorieName);
holder.grid_item_label.setText(categorieName);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().post(event);
}
});
}
Run Code Online (Sandbox Code Playgroud)
主要活动:
@Override
public void onCreate(Bundle savedInstanceState) {
linearLayoutManager = new LinearLayoutManager(this);
listAdapter = …Run Code Online (Sandbox Code Playgroud) 我有一个视图层次结构,如下图所示。
我遇到奇怪的滚动行为,例如,
AppBar随之崩溃。这可以。AppBar不会倒塌。它停留在那里并RecyclerView进入其下方。然而,它在快速运行时效果很好。activity_challenge_detail.xml
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="@+id/swipeRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".challengedetail.ChallengeDetailActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/black">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="@color/black"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.2">
<FrameLayout
android:id="@+id/challengeBannerFrame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:foreground="@drawable/banner_gradient"
app:layout_constraintDimensionRatio="H,1:1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/challengeBanner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/challenge_banner"
android:scaleType="centerCrop"
tools:src="@tools:sample/avatars" />
</FrameLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.appcompat.widget.Toolbar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minHeight="@dimen/dp16"
app:layout_collapseMode="pin">
<com.company.widget.StatusBarSpacer
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp"
app:layout_collapseMode="pin">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android android-layout android-coordinatorlayout android-viewpager2