android高级控件-Fragment

  Frament+ViewPager

 viewpage可以做简单的导航,到页面菜单,可以使用视图滑动,实现像lanucher左右滑动等等,

  在布局文件中加入控件viewpager,这个组件,注意这个组件是用来显示左右滑动的界面的,如果不加载xml布局文件,他是不会显示内容的


 1.frament作为activity界面的一部分组成出现。
 2.可以一个activity界面同时出现对个frament,并且一个frament也可以再多个activity中使用
 3.在activity运行中可以动态添加,移除,替换frament

结果如下:能够自由切换效果


这是主页面

[html]  view plain   copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <LinearLayout  
  3.     xmlns:android="http://schemas.android.com/apk/res/android"  
  4.     xmlns:app="http://schemas.android.com/apk/res-auto"  
  5.     xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"  
  6.     android:layout_height="match_parent"  
  7.     tools:context="com.example.android_pagetframent.MainActivity"  
  8.     android:orientation="vertical"  
  9.     >  
  10.   
  11.     <android.support.v4.view.ViewPager  
  12.         android:layout_width="match_parent"  
  13.         android:layout_height="match_parent"  
  14.         android:layout_weight="1"  
  15.         android:id="@+id/Res_ViewPager">  
  16.     </android.support.v4.view.ViewPager>  
  17.   
  18.     <RadioGroup  
  19.         android:layout_width="match_parent"  
  20.         android:layout_height="wrap_content"  
  21.         android:orientation="horizontal"  
  22.         android:id="@+id/res_RadioGroup"  
  23.   
  24.         >  
  25.         <RadioButton  
  26.             android:layout_width="wrap_content"  
  27.             android:layout_height="wrap_content"  
  28.             android:drawableTop="@drawable/xiao"  
  29.             android:background="@drawable/yanse"  
  30.             android:paddingLeft="60dp"  
  31.             android:text="微信"  
  32.             android:button="@null"  
  33.             android:id="@+id/res_1"  
  34.             />  
  35.   
  36.         <RadioButton  
  37.             android:id="@+id/res_2"  
  38.             android:layout_width="wrap_content"  
  39.             android:layout_height="wrap_content"  
  40.             android:background="@drawable/yanse"  
  41.             android:button="@null"  
  42.             android:drawableTop="@drawable/xiao"  
  43.             android:paddingLeft="100dp"  
  44.             android:text="通讯录" />  
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值