MobliePlayer主页面底部导航栏
文章目录
1. 主页面总体布局
主页面总体布局为线性布局LinearLayout,在线性布局上采用FrameLayout和RadioGroup占满整个页面,再在RadioGroup中采用4个RadioButton设置导航图标及文字用于主页面FrameLayout内容切换。
2. 线性布局
全页面采用一个线性布局(LinearLayout),因FrameLayout和RadioGroup为上下关系,所以在线性布局中要设置方向orientation。代码如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
3. FrameLayout
主页面的上部是一个帧布局(FrameLayout),高度采用0dp配合权重占满主页面上部,注意,高度为0dp时,必须配合weight权重进行设置,不然高度0dp报红。代码如下:
<FrameLayout
android:id="@+id/fl_main"
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_height="0dp" />
4. RadioGroup
RadioGroup是主页面下部的导航按纽的容器,导航按纽是水平排列的4个,所以在RadioGroup中需要设置方向orientation为horizontal,设置每个导航按纽居中android:gravity=“center_vertical”,其余的距离,颜色,高和宽设置如下:
<RadioGroup
android:id="@+id/rg_main"
android:gravity="center_vertical"
android:padding="5dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#22000000">
5. RadioButton
这个是装在RadioGroup容器中,水平排列的代码由RadioGroup中的orientation设置,其中一个RadioButton代码如下:
<RadioButton
android:button="@null"