利用RadioButton实现底部导航栏

本文介绍了如何利用RadioButton创建底部导航栏,通过布局文件设置RadioGroup和RadioButton,调整权重并设置图标。接着,通过编写代码实现Fragment的切换,监听底部导航的改变,利用FragmentTransaction进行界面隐藏和显示,从而实现底部导航栏的功能。
摘要由CSDN通过智能技术生成

目标:利用RadioButton实现底部导航栏

简介:底部导航栏是现在大部分app都会用到的功能
它帮助用户可以通过导航在不同界面自由切换

实现过程

步骤1:编写布局文件
用RadioGroup和RadioButton完成导航栏的布局
用weight属性来控制所占比例
图片用系统所自带的一些图片
准备一定空间放置FrameLayout用于之后跳转

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">
    <FrameLayout
        android:id="@+id/main_Frame"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1">
    </FrameLayout>
    <ImageView
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@color/spe"/>
    <RadioGroup
        android:id="@+id/main_menu"
        android:background="@color/menu"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值