- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在使用以下布局文件来实现带有折叠工具栏的协调器布局(当用户向下滚动时,它应该折叠,并在他们向上滚动时重新出现)但是,这种滚动屏幕/折叠功能不起作用,并且我不知道为什么。工具栏和标签栏没有反应,而是静态地停留在屏幕顶部。
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Alpha" />
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Beta" />
<!-- a bunch of content just to make the view long enough to scroll -->
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Upsilon" />
</LinearLayout>
</ScrollView>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorAccent"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways" />
<!-- ^^^^^^^^^^^^^^^^^^ -->
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways" />
<!-- ^^^^^^^^^^^^^^^^^^ -->
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_padding"
android:src="@drawable/ic_add"/>
</android.support.design.widget.CoordinatorLayout>
有什么帮助吗?谢谢!
最佳答案
据我所知,ScrollView不起作用。您可以使用 NestedScrollView或 RecyclerView相反。
关于android - 在 CoordinatorLayout 中滚动时工具栏不会折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32448579/
根据我目前的阅读,Behavior 只能应用于 CoordinatorLayout 的直接子级。但是下面的代码让我感到困惑:
CoordinatorLayout 在另一个 CoordinatorLayout 中,这样滚动 subview 也应该滚动父 CoordinatorLayout。 我有一个 coordinatorLa
我正在创建一个 Android 应用程序,我想隐藏 BottomAppBar (它有一个固定在中心的工厂)每当我滚动 RecyclerView谁在我的 Activity fragment 内而不更改
我提到了 This Question但没有答案对我有用。所以基本上我有一个 BottomNavigationView,它在向下滚动时隐藏并在向上滚动时显示。当我通过触摸滚动 Recycler View
我想向 CoordinatorLayout 添加一个页脚,其中包含一个 TabView + ViewPager。 这是 main.xml:
我有一个 CoordinatorLayout 并且我想要一个 FrameLayout 位于所有其他 Layouts 和 widgets 之下。我试过使用 android:layout_below/ab
我想用 RecyclerView 和 Toolbar 创建简单的 CoordinatorLayout,但与标准解决方案的区别在于 Toolbar 应该在底部,并且当 RecyclerView 滚动到底
我可以在我的 xml 文件中使用协调器布局,但是当我尝试将它导入我的 java 类时,它说“无法解析符号 CoordinatorLayout,而同一包中的其他类工作正常。 截图如下: 依赖项: 最佳答
我正在使用单个 Activity - 多个 fragment 结构。在 Activity 中,我使用 v7 工具栏作为操作栏。我有一些带有 viewpager 的 fragment ,有些也带有标签。
这让我抓狂。这两天我一直在努力完成这项工作,但没有取得任何进展。我想要一个应用程序栏,它在我向下滚动 ViewPager 时隐藏,并在我向上滚动 ViewPager 时显示,这似乎是标准的做法。
我需要创建一个具有线性布局的 Coordinatorlayout 和一个具有相同空间的 RecyclerView。 我试过将 layout_weight 设置为 0.5,但 RecyclerView
我尝试通过 CoordinatorLayout 获得此结果,但无法在背景上设置全屏图像,该图像在整个屏幕上展开,与图像中相同。我尝试了几种方法,例如将 LinearLayout 放入 Collapsi
我有一个包含 3 个使用回收 View 的 fragment 的 viewpager。当用户滚动回收 View 时,我试图隐藏工具栏。我的问题是工具栏在用户滚动时隐藏/显示但没有完全隐藏。我不明白我做
我有一个抽屉的主要 Activity ,抽屉有一个容器布局,我用 FragmentManager 替换每个 fragment 。 我想在滚动上隐藏/显示的我的一个子 fragment 中添加一个 FA
这里我有一个相当复杂的动画,可以使用 CoordinatorLayout 以简单的方式解决(我相信) .它有 3 个状态: 初始(左侧屏幕)- 标题 View 完全显示(橙色 背景):工具栏,灰色 r
我有一个全屏显示的 Activity。这适用于我尝试过的许多布局,但当 CoordinatorLayout 是根 ViewGroup 时除外。 CoordinatorLayout 本身的宽度和高度都设
看看下面的布局。您会看到, float 按钮距离底部太远。这是因为显示了 Toolbar 和 Tabs,并且 ViewPager 的高度不正确。所以不知何故我在 layout_height 上做错了什
我是 android Material 设计方面的新手。所以,请多多包涵。我尝试为我的家庭 Activity 实现 FAB,然后实现 snackbar 。自然,它高于我的 FAB。我研究了 Coord
我正在尝试从新发布的 Android Design Support Library 中实现 CoordinatorLayout并且我根据示例 here 在我的 XML 布局中使用了以下代码:
我正在尝试使用 RecyclerView 和 TextView 实现 CoordinatorLayout,其中 TextView 将根据您滚动 RecyclerView 的方式进行动画处理。但是我的自
我是一名优秀的程序员,十分优秀!