【问题标题】:how to navigation bar at the bottom如何在底部导航栏
【发布时间】:2019-04-18 14:11:22
【问题描述】:

我已使用此代码绑定..

<android.support.design.widget.BottomNavigationView
            android:id="@+id/navigation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="?android:attr/windowBackground" />
//parent views are Relative Layout then ScrollView

它随着屏幕的滚动而移动,但我希望导航栏是固定的,即使在滚动屏幕之后,任何人都可以帮助我吗? 就像 Messenger 应用程序一样,我希望它得到修复!

【问题讨论】:

  • “它随着屏幕的滚动而移动”,这是什么意思?您的视图是在 Scrollview 中定义的吗?
  • 您的问题将大大改善 1. 一些正在发生的屏幕视频(使用 android studio 抓取视频然后转换为动画 gif 很容易) 2. 更多显示父级的 .xml 代码) 和 BottomNavigationView 的兄弟姐妹

标签: android android-layout uinavigationbar


【解决方案1】:

-你可以使用下面的代码或类似的东西......

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

    </RelativeLayout>
</ScrollView>
 <com.google.android.material.bottomnavigation.BottomNavigationView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

【讨论】:

  • java.lang.RuntimeException: Unable to start activity ComponentInfo{phyla.admin.com.phyla/phyla.admin.com.phyla.plantDetails}: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.coordinatorlayout.widget.CoordinatorLayout Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class androidx.coordinatorlayout.widget.CoordinatorLayout Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.coordinatorlayout.widget.CoordinatorLayout"
【解决方案2】:
 <android.support.design.widget.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"/>

我明白了!它是固定的,不影响滚动根布局的是相对布局。 感谢您的帮助 Amit Ghoswani 先生

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-20
    • 1970-01-01
    相关资源
    最近更新 更多