如何在应用顶部显示底部导航视图?

问题描述 投票:-2回答:2

我想在我的应用程序顶部显示底部导航视图,如facebook,我试试这个,但它没有显示任何东西。

java android
2个回答
0
投票

使用TabLayout,你会有类似的东西。以下是我认为可以帮助您的视频。你需要使用FragmentsTabLayout

https://codinginflow.com/tutorials/android/tab-layout-with-fragments


0
投票

底部导航视图的放置位置无关紧要,您只需将其放置在布局的顶部即可。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"
        app:itemIconTint="@color/bottom_navigation_colors"
        app:itemTextColor="@color/black"
        app:menu="@menu/bottom_navigation_menu"
        app:labelVisibilityMode="labeled"/>


    <androidx.viewpager.widget.ViewPager
        android:id="@+id/viewpager"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

</LinearLayout>
© www.soinside.com 2019 - 2024. All rights reserved.