Android UI-实现底部切换标签之方式一 ──fragment(底部采用radioGroup+radiobutton)添加5个子fragment

这篇博客介绍了如何在Android应用中实现底部切换标签功能,采用RadioGroup和RadioButton结合Fragment的方式,添加了5个子Fragment。文章详细讲解了在原有功能基础上增加的改进,包括隐藏不需要侧滑菜单的子Fragment的侧滑图标,禁用侧滑菜单,修改子Fragment标题,以及自定义ViewPager以阻止滑动。提供了相关布局文件和自定义ViewPager的实现,并附带了Demo下载链接。
摘要由CSDN通过智能技术生成



此功能是在上一篇博客的基础上进行改进,增加了底部切换标签,此处是使用Fragment,底部使用radioGroup+radioButton,添加5个子fragment到该Fragment

在这个小案例中添加了一些小细节:

1.将不需要有侧滑菜单的子Fragment进行隐藏侧滑图标

2.定义一个方法使该页面真正不能有侧滑菜单

3.更改各个子Fragment的标题

4.自定义ViewPager利用事件分发机制禁止ViewPager的左右滑动


首先是布局文件

<?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:orientation="vertical">

    <com.jhy.drawerlayoutdemo.CustomViewPager
        android:id="@+id/vp_content"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1">

    </com.jhy.drawerlayoutdemo.CustomViewPager>

    <RadioGroup
        android:id="@+id/rg_content"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal">

        <RadioButton
            android:id="@+id/rb_home"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:button="@null"
            android:drawableTop="@mipmap/ic_launcher"
            android:gravity="center"
            android:textColor="#9b979a"
            and
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值