【发布时间】:2019-05-03 07:47:23
【问题描述】:
我正在为我的 android 应用程序使用带有视图寻呼机的底部导航栏 它有 5 个选项卡,我希望中间选项卡循环或像中间的浮动操作栏
这就是想法 https://github.com/ittianyu/BottomNavigationViewEx/blob/master/read_me_images/center_fab.jpg
【问题讨论】:
标签: android android-layout android-xml
我正在为我的 android 应用程序使用带有视图寻呼机的底部导航栏 它有 5 个选项卡,我希望中间选项卡循环或像中间的浮动操作栏
这就是想法 https://github.com/ittianyu/BottomNavigationViewEx/blob/master/read_me_images/center_fab.jpg
【问题讨论】:
标签: android android-layout android-xml
它使用官方库,遗憾的是它们仍处于 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>
你应该很高兴
【讨论】: