我正在为我的android应用程序使用底部导航栏和查看寻呼机 并且它有5个标签,我希望中间标签呈圆形或像中间的浮动操作栏
这是个主意 https://github.com/ittianyu/BottomNavigationViewEx/blob/master/read_me_images/center_fab.jpg
答案 0 :(得分:0)
它使用的是官方图书馆,但遗憾的是它们仍处于alpha阶段,但对我来说很好用。 简而言之: 添加
implementation 'com.google.android.material:material:1.1.0-alpha05'
到您的build.gradle
然后像这样建立您的activity.xml:
<androidx.coordinatorlayout.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">
<Your content here>
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottom_appbar"
style="@style/Widget.MaterialComponents.BottomAppBar.Colored"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:hideOnScroll="true"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIcon="@drawable/ic_menu_white_24dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_stop_white_24dp"
app:backgroundTint="@color/colorAccent"
app:layout_anchor="@+id/bottom_appbar"
app:tint="@color/colorWhite" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
你应该很好走