【问题标题】:Android TabLayout scroll up animation with listfragmentAndroid TabLayout 使用 listfragment 向上滚动动画
【发布时间】:2015-11-25 00:00:26
【问题描述】:

我的主要 xml 设置如下:

<android.support.design.widget.AppBarLayout
    android:id="@+id/appbar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:fitsSystemWindows="true">

    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        app:layout_scrollFlags="scroll|enterAlways"/>

    <android.support.design.widget.TabLayout
        android:id="@+id/tabLayout"
        android:scrollbars="horizontal"
        android:layout_below="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary" />

</android.support.design.widget.AppBarLayout>

<android.support.v4.view.ViewPager
    android:id="@+id/tab_view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"

    app:layout_behavior="@string/appbar_scrolling_view_behavior"/>

<!-- Your Scrollable View -->
<!--<include layout="@layout/cardviews"/>-->

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@drawable/ic_note_add_white_48dp"
    android:layout_marginBottom="20dp"
    android:layout_marginRight="20dp"
    android:layout_gravity="bottom|right"
    app:fabSize="normal" />

在我所关注的教程中,他们实现了卡片视图的滚动列表,当列表滚动时,它会向上推选项卡布局。

但是,这里我有一个视图寻呼机,而不是水平滚动的卡片视图列表。在视图寻呼机的页面中,我有一个包含垂直列表的列表片段。

然而,当我在视图分页器中滚动这个垂直列表时,选项卡布局并没有向上推!

如何让这个嵌套的 listfragment 与选项卡布局交互。

【问题讨论】:

  • 您可以在Fragment 中使用RecyclerView 而不是ListFragment

标签: java android xml android-layout android-fragments


【解决方案1】:

AppBar 仅在您使用 NestedScrollViewRecyclerView 时才会如此。这两个类都实现了NestedScrollingChild,我猜你的ListFragment 没有使用这些类中的任何一个来实现列表功能。

【讨论】:

  • 那么如果我用我的列表片段实现嵌套滚动子项,它会起作用吗?
  • 它看起来应该基于您的 XML,但为了简单起见,如果可以的话,我会切换到回收站视图。
  • 能否请您指出一些我可以研究的资源?谢谢!
  • @WayWay 试试这个吧? stackoverflow.com/questions/30696611/…
猜你喜欢
  • 1970-01-01
  • 2023-02-14
  • 2015-11-17
  • 1970-01-01
  • 2015-07-17
  • 1970-01-01
  • 1970-01-01
  • 2021-04-04
  • 1970-01-01
相关资源
最近更新 更多