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=&#