- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有两个案例。两者都有错误。
根元素是 ConstraintLayout
。 Fragment
元素与 NavHostFragment
(RecycleView
内)。 BottomNavigationView
连接到 bottom
。 错误:CollapsingToolbarLayout
的滚动动画不起作用。
根元素是 CoordinatorLayout
。 CollapsingToolbarLayout
的动画效果很好。 错误:BottomNavigationView
覆盖了 RecycleView
的最后一项。
两张动图。注意 AppBar 和日期 2019 年 8 月 5 日(在底部)。
请帮助修复布局,使最后一个元素不覆盖 BottomNavigationView
和工作的 AppBar 动画。
第一个案例
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
app:layout_constraintBottom_toTopOf="@+id/frame"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
style="@style/ToolbarTextAppearanceStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintBottom_toTopOf="@+id/nav_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/app_bar">
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_main" />
</FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="?mainBackgroundColor"
app:itemIconTint="@drawable/bottom_navigation_colors"
app:itemTextColor="@drawable/bottom_navigation_colors"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/menu_botton_navigation" />
</androidx.constraintlayout.widget.ConstraintLayout>
第二种情况
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="@dimen/app_bar_height"
android:fitsSystemWindows="true"
app:layout_constraintBottom_toTopOf="@+id/frame"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar_layout"
style="@style/ToolbarTextAppearanceStyle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:toolbarId="@+id/toolbar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<fragment
android:id="@+id/nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/navigation_main" />
</FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?mainBackgroundColor"
android:layout_gravity="bottom"
app:itemIconTint="@drawable/bottom_navigation_colors"
app:itemTextColor="@drawable/bottom_navigation_colors"
app:menu="@menu/menu_botton_navigation" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
最佳答案
添加到 RecyclerView
下一个:
<!-- android:paddingBottom="@dimen/bottom_navigation_height" -->
android:paddingBottom="150dp"
android:clipToPadding="false"
关于java - BottomNavigationView 与 RecycleView 的最后一项重叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57420567/
这是我的代码: class MainActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) {
Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line #19: Error
我正在努力实现这样的目标 https://material.google.com/components/bottom-navigation.html#bottom-navigation-behavio
我有一个 bottomnavigation View ,它根据是否选中的状态设置一个图标。 bottomnav_icon_home: 当 androi
我知道我们可以通过 this 中的 XML 设置底部导航选择颜色方式 但我想知道如何从我的 Activity 中以编程方式更改它? 这是我在 Activity 的 OnNavigationItemSe
升级依赖后: 'com.google.android.material:material:x.x.x' 来自 1.4.0 至 1.5.0 ,导航项文本以某种方式从锚定在图标下方更改为在图标上方: 从:
我正在创建一个包含 BottomNavigationView 的应用程序,但在更新库后 com.google.android.material:material:1.5.0我的应用在图标上显示标签。
我想更改BottomNavigationView高度和更改尺寸后项目位置不会改变。 这更像是中间的间隙不会自动改变。但是,我想更改这个间隙大小。 This is Before change heigh
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 4 年前。 Improve this ques
如何设置margin到bottomNavigation的徽章 Material 成分?? 或者 我们怎样才能防止到padding当我们点击 bottomNavigationView 中的一个项目时因此
我在 sdp Library 的帮助下创建了布局和 ssp Library , 在 Nexus 10 API 24 模拟器中测试时,BottomNavigationView 显示图标和文本标签相互重叠
我正在使用 BottomNavigationView但不知何故,当我完全点击项目的文本时,我无法导航到另一个项目,因为点击被拦截了。这是一个大问题,因为文本占据了按钮的一半。如果我长按它实际上会选择文
我的主要 Activity 中有一个 BottomNavigationView,并且我已经尝试了一切方法来尝试使按钮(项目)不可点击。 在 BottomNavigationView 的 main_me
当我刚刚单独创建BottomNavigationView时效果很好。但是将 BottomNavigationView 与 Fragment 一起使用有问题。问题是 Fragment 更改得很好,但 B
我是 Kotlin 开发新手。我正在尝试执行 BottomNavigationView,一切正常,但是当我想为 ItemSelected Listener 创建 BottomNavigationVie
我正在尝试实现简单的 BottomNavigationView。 fragment 根据单击的项目正确运行,但 setOnNavigationItemSelectedListener 似乎不会为我的
我一直在尝试让 BottonNavigationView 正常工作。它只是一直粘在布局的顶部,这让我发疯。 我查看了 BottomNavigationView 的 Material 设计文档,它看起来
我正在开发 Android 应用程序。有一个名为 HomeActivity 的 Activity ,上面有一个 BottomNavigationView。 还有几个 fragment 。 我从名为 S
我尝试设置底部导航项的文本颜色。 This guide表示有一个名为 setSelectedItemId 的函数以编程方式设置所选项目。但它需要 25.3.0 支持库,我使用 25.0.0。所以我使用
有没有一种简单的方法可以在 BottomNavigationView 的项目之间手动切换? ? 我在源代码中找不到任何相关方法。 最佳答案 好的,在官方更新解决此问题之前,我找到了一个临时解决方法。
我是一名优秀的程序员,十分优秀!