MobliePlayer主页面底部导航栏

本文详细介绍了MobliePlayer主页面底部导航栏的实现,包括线性布局、FrameLayout、RadioGroup和RadioButton的使用。通过RadioButton的文字颜色选择器和图片选择器,实现了根据选中状态动态改变文字颜色和图片。同时,通过样式抽取,优化了代码结构,提高了代码复用性。
摘要由CSDN通过智能技术生成

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"	
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值