Android VR Player(全景视频播放器) [3]:底部导航的实现

本文介绍了如何在Android VR Player中实现底部导航,遵循Material Design规范。步骤包括添加依赖、在布局中添加Bottom Navigation组件、准备Fragment以及使用BottomNavigationBar。文章还提供了代码示例和调试运行的结果。
摘要由CSDN通过智能技术生成

Android VR Player(全景视频播放器) [3]:底部导航的实现

底部导航介绍

本篇主要分享Material design中Bottom Navigation的实现过程,先看效果图:
Bottom Navigation
(图片来源:https://github.com/Ashok-Varma/BottomNavigation
Bottom Navigation导航方式在今天很多APP上都可以看到,可以说是Android中的底部导航规范了,所以学习一下它的使用还是很有必要的。


实现步骤

添加依赖

在项目app的build.gradle文件的dependencies {}中添加

compile 'com.ashokvarma.android:bottom-navigation-bar:1.4.3'

然后同步一下配置

在布局中添加Bottom Navigation组件

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.renkangchen.bottomnavigationbardeme.MainActivity">

    <FrameLayout
        android:id="@+id/fragment_content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1"/>

    <com.ashokvarma.bottomnavigation.BottomNavigationBar
        android:id="@+id/bottom_navigation_bar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

(activity_main.xml代码片段)

上面是一个可参考的示例,注意BottomNavigationBar上面的FrameLayout,它用来“占位”,也就是把BottomNavigationBar“挤”到页面的底部

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值