Android之tab实现切换页面效果—FragmentTabHost

本文介绍了如何在Android中使用FragmentTabHost实现点击Tab切换页面的效果,详细讲解了从主页面布局到每个Tab的创建,以及点击时背景图标的变换,并提供了MainActivity的实现过程。最终展示了简单的页面切换效果。
摘要由CSDN通过智能技术生成

android常见的视觉效果,通过点击下方的Tab实现页面切换效果,用到的即是TabHost的子类之一:FragmentTabHost,他的好处即在于可以方便的编写具体页面内容,实现步骤如下:

1、主页面布局 —— activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.android_myewj.MainActivity" >

    <FrameLayout 
        android:id="@+id/realtabcontent"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"/>
    <android.support.v4.app.FragmentTabHost
        android:i
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值