- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个包含 3 个使用回收 View 的 fragment 的 viewpager。当用户滚动回收 View 时,我试图隐藏工具栏。我的问题是工具栏在用户滚动时隐藏/显示但没有完全隐藏。我不明白我做错了什么。为了说明到底发生了什么,我添加了两张带有工具栏两种状态(隐藏和显示)的图片。
注意:工具栏隐藏时我注意到一件事。它并没有像它应该的那样位于系统状态栏的“下方”,而是位于其上方。
可以看出,工具栏没有完全隐藏。我可以在右侧看到部分工具栏标题和溢出图标。
这是我的 main_layout xml:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fab="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:fitsSystemWindows="true"
tools:context="com.studentsins.lust.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"
app:layout_scrollFlags="scroll|enterAlways" />
<android.support.design.widget.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/NavigationTab"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
<include layout="@layout/content_main"/>
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:id="@+id/floatingActionMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
fab:fab_addButtonColorNormal="@color/blood_orange"
fab:fab_addButtonColorPressed="@color/dirtyWhite"
fab:fab_addButtonPlusIconColor="@color/dirtyWhite"
fab:fab_addButtonSize = "normal"
fab:fab_labelStyle="@style/menu_labels_style"
fab:fab_labelsPosition="left"
app:layout_anchor="@id/viewpager"
app:layout_anchorGravity="bottom|end">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/createPlanBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/blood_orange"
fab:fab_title="Create a plan"
fab:fab_size="normal"
app:fab_icon="@drawable/ic_event_white_48dp"
fab:fab_colorPressed="@color/dirtyWhite"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/changeStatusBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_colorNormal="@color/blood_orange"
fab:fab_size="normal"
app:fab_icon="@drawable/ic_textsms_white_48dp"
fab:fab_title="Change status"
fab:fab_colorPressed="@color/dirtyWhite"/>
</com.getbase.floatingactionbutton.FloatingActionsMenu>
</android.support.design.widget.CoordinatorLayout>
最佳答案
找到了解决该问题的方法。在 v21/Styles.xml 中
我必须将“android:statusBarColor”从“transperant”更改为任何颜色。
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@color/tab_bg</item>
</style>
关于android - 滚动时隐藏工具栏无法正常工作 [CoordinatorLayout],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35325914/
根据我目前的阅读,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 的方式进行动画处理。但是我的自
我是一名优秀的程序员,十分优秀!