主页面布局框架搭建

本文介绍了如何在Android中搭建主页面布局框架,包括布局方式、公共属性布局和数据区域布局的实现。通过使用RadioButton、ViewPager和Fragment,实现了底部导航栏与内容区域的动态切换,其中内容区域使用线性布局填充不同标题和内容。
摘要由CSDN通过智能技术生成

1 布局方式:

由于在主页面现在内容是一个空的Fragment,现在需要往这个空的Fragment添加有内容的Fragment.

最终的实现效果是:

     

可以看出

1 下面一排是RadioButton 

2 页面切换可以看做变化的Viewpager作为底板

3 ViewPager上使用线性布局的方式,放入不同的标题,以及内容(内容依旧使用Fragment布局方式进行填充)


下面是用于填充空Fragment的XML布局,是橘黄色框和浅蓝色框的布局实现。

<?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">
 
    <!-- 这里调用了自定义了一个继承ViewPager的类:NoScrollViewPager,这个类重写了 onTouchEvent,使其不产生左右滑动的效果-->
    <com.example.zhihuibj.view.NoScrollViewPager
        android:id="@+id/vp_content"
        android:layout_width="match_parent"
        android:layout_height="0dp" 
        android:layout_weight="1" />
   
    
    
    <RadioGroup 
        android:id="@+id/rg_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:background="@android:color/darker_gray"        
        >
        <RadioButton   
            android:id="@+id/rb_home"         
			style="@style/BottomTab"
            android:text=&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值