=================================
前言
–
本篇博客要分享的一个UI效果——实现底部切换标签,想必大家在一些应用上面遇到过这种效果了,最典型的就是微信了,可以左右滑动切换页面,也可以点击标签页滑动页面,它们是如何实现的呢,本篇博客为了简单只介绍如何实现点击底部切换标签页。
先来看看我们想实现的效果图:
这样的页面实现起来其实很简单的,首先我们从布局入手:
分为三部分
第一部分:顶部导航栏布局
第二部分:中部显示内容布局
第三部分:底部标签布局
/BottomTabDemo/res/layout/activity_main.xml
<FrameLayout xmlns:android=“http://schemas.android.com/apk/res/android”
android:layout_width=“match_parent”
android:layout_height=“match_parent” >
<RelativeLayout
android:id=“@+id/rl_main”
android:layout_width=“match_parent”
android:layout_height=“match_parent” >
<RelativeLayout
android:id=“@+id/top_tab”
android:layout_width=“match_parent”
android:layout_height=“50dip”
android:background=“@color/topbar_bg” >
<ImageView
android:id=“@+id/iv_logo”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerInParent=“true”
android:focusable=“false”
android:src=“@drawable/zhidao_logo”
android:contentDescription=“@null” />
<LinearLayout
android:id=“@+id/ll_bottom_tab”
android:layout_width=“match_parent”
android:layout_height=“54dp”
android:layout_alignParentBottom=“true”
android:gravity=“center_vertical”
android:orientation=“horizontal”
android:baselineAligned=“true”>
<RelativeLayout
android:id=“@+id/rl_know”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1.0” >
<ImageView
android:id=“@+id/iv_know”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerHorizontal=