页面切换的3种实现

页面切换的实现


这里要实现页面切换的三种方式:
方法一: 首页等ViewPager(配合Fragment或View) + LinearLayout(配合TextView)框架搭建;
方法二: ViewPagerIndicator 或使用 PagerSlidingTab实现;
方法三: 用Fragment + frameLayout;


方式一:主要是思路,先看布局吧:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

  <!--  <ui.PagerSlidingTab		//方式三:自定义的Tab类,后边有介绍
        android:id="@+id/pager_tab"
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:background="@drawable/selector_color"
        app:dividerColor="#00000000"
        app:shouldExpand="true"
        app:indicatorColor="#40AA53"/>-->

      <com.viewpagerindicator.TitlePageIndicator   //方式三:页面切换---页面上边Tab控制
       android:id="@+id/pager_tab"
       android:padding="10dip"
       android:layout_height="45dp"
       android:layout_width="fill_parent"
       android:background="#18FF0000"
       android:textColor="#AA000000"
       app:footerColor="#FFAA2222"
       app:footerLineHeight="1dp"
       app:footerIndicatorHeight="3dp"
       app:footerIndicatorStyle="underline"
       app:selectedColor="#FF000000"
       app:selectedBold="true"
       />

    <android.support.v4.view.ViewPager		//方式一:页面切换---页面下边TextView控制
        android:id="@+id/vp"
        android:layout_above="@+id/view"
        android:layout_below="@+id/pager_tab"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/green" />

    <View
        android:id="@+id/view"
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:background="@android:color/darker_gray"
        android:layout_above="@+id/ll" />

    <LinearLayout
        android:id="@+id/ll"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@android:color/background_light"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/tv1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/selector_draw"
            android:text="dddddd"
            android:gravity="center"
            android:textColor="@color/selector_tv"
            android:textSize="14sp" />

        <TextView
            android:id="@+id/tv2"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/selector_draw2"
            android:text="ddd"
            android
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值