Android UI-实现底部切换标签(fragment),安卓客户端开发面试题目

本文介绍了如何在Android应用中实现底部切换标签页的UI效果,类似于微信的功能。文章通过布局设计和代码示例,详细展示了如何通过点击底部标签切换不同的Fragment,包括顶部导航栏、中部内容和底部标签的布局设计,以及Fragment的切换方法。
摘要由CSDN通过智能技术生成

=================================

前言

本篇博客要分享的一个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=

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值