android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1.0” >
<ImageView
android:id=“@+id/iv_i_want_know”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerHorizontal=“true”
android:src=“@drawable/btn_wantknow_nor”
android:contentDescription=“@null” />
<TextView
android:id=“@+id/tv_i_want_know”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/iv_i_want_know”
android:layout_centerHorizontal=“true”
android:text=“@string/bottom_tab_wantknow”
android:textColor=“@color/bottomtab_normal”
android:textSize=“12sp” />
<RelativeLayout
android:id=“@+id/rl_me”
android:layout_width=“0dp”
android:layout_height=“wrap_content”
android:layout_weight=“1.0” >
<ImageView
android:id=“@+id/iv_me”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_centerHorizontal=“true”
android:src=“@drawable/btn_my_nor”
android:contentDescription=“@null” />
<TextView
android:id=“@+id/tv_me”
android:layout_width=“wrap_content”
android:layout_height=“wrap_content”
android:layout_below=“@+id/iv_me”
android:layout_centerHorizontal=“true”
android:text=“@string/bottom_tab_my”
android:textColor=“@color/bottomtab_normal”
android:textSize=“12sp” />
<LinearLayout
android:id=“@+id/content_layout”
android:layout_width=“match_parent”
android:layout_height=“match_parent”
android:layout_above=“@+id/line”
android:layout_below=“@+id/top_tab”
android:orientation=“vertical” >
<View
android:id=“@+id/line”
android:layout_width=“match_parent”
android:layout_height=“1dp”
android:layout_above=“@id/ll_bottom_tab”
android:background=“@color/line” />
以上是布局代码,下面就介绍如何通过点击标签切换Fragment:
我们会发现,初始的时候是选中第一个标签页