实现效果:
左右滑动可切换界面,点击也可以实现
界面与碎片:
主界面:
<?xml version="1.0" encoding="utf-8"?>
<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="com.example.g160628_android10_viewpagerfragment_zuoye.MainActivity">
<!--设置ViewPager与单选组-->
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/vp_main_view"
android:layout_weight="1"
></android.support.v4.view.ViewPager>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="@+id/rg_main_group"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/button_selector"
android:id="@+id/rb_main_bu1"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/button2_selector"
android:id="@+id/rb_main_bu2"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:button="@null"
android:background="@drawable/button3_selector"
android:id="@+id/rb_main_bu3"
/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layou