Frament+ViewPager
viewpage可以做简单的导航,到页面菜单,可以使用视图滑动,实现像lanucher左右滑动等等,
在布局文件中加入控件viewpager,这个组件,注意这个组件是用来显示左右滑动的界面的,如果不加载xml布局文件,他是不会显示内容的
1.frament作为activity界面的一部分组成出现。
2.可以一个activity界面同时出现对个frament,并且一个frament也可以再多个activity中使用
3.在activity运行中可以动态添加,移除,替换frament
结果如下:能够自由切换效果
这是主页面
- <?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"
- tools:context="com.example.android_pagetframent.MainActivity"
- android:orientation="vertical"
- >
-
- <android.support.v4.view.ViewPager
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_weight="1"
- android:id="@+id/Res_ViewPager">
- </android.support.v4.view.ViewPager>
-
- <RadioGroup
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal"
- android:id="@+id/res_RadioGroup"
-
- >
- <RadioButton
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:drawableTop="@drawable/xiao"
- android:background="@drawable/yanse"
- android:paddingLeft="60dp"
- android:text="微信"
- android:button="@null"
- android:id="@+id/res_1"
- />
-
- <RadioButton
- android:id="@+id/res_2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:background="@drawable/yanse"
- android:button="@null"
- android:drawableTop="@drawable/xiao"
- android:paddingLeft="100dp"
- android:text="通讯录" />
-