页面切换的实现
这里要实现页面切换的三种方式:
方法一: 首页等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