android布局学习-使用FrameLayout和LinearLayout制作QQ空间底部导航栏

【声明:本博客通过学习“J灬叶小超 ”博客而写,链接:http://www.cnblogs.com/yc-755909659/p/4288260.html

--------------------------------------------------------------------------------------------------------

界面效果如下所示:

-------------------------------------------------------------------------------------------------------------

【分析】

此导航栏的设计通过FrameLayout和LinearLayout编写,我们知道每个FrameLayout都是具有叠加效果:(通过图片可以进一步理解)

对这个分析,小编花了一个图:

-------------------------------------------------------------------------------------------------------------

【代码】

<RelativeLayout 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">

    <FrameLayout
        android:id="@+id/frame_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/frameMenu"
        android:layout_alignParentTop="true">
        </FrameLayout>

    <FrameLayout
        android:id="@+id/frameMenu"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/skin_tabbar_bg"
            android:orientation="horizontal">
            <!--动态-->
            <FrameLayout
                android:id="@+id/layout_at"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1">
                <ImageView
                    android:id="@+id/image_at"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|center"
                    android:background="@drawable/skin_tabbar_icon_auth_select"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom|center"
                    android:text="@string/skin_tabbar_icon_auth"
                    android:textSize="12sp"/>
            </FrameLayout>
            <!-- 与我相关 -->

            <FrameLayout
                android:id="@+id/layout_auth"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/image_auth"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|center"
                    android:src="@drawable/skin_tabbar_icon_at_select" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom|center"
                    android:text="@string/skin_tabbar_icon_at"
                    android:textColor="@android:color/black"
                    android:textSize="12sp" />
            </FrameLayout>
            <!-- 留白 -->

            <FrameLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" >
            </FrameLayout>
            <!-- 我的空间 -->

            <FrameLayout
                android:id="@+id/layout_space"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/image_space"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|center"
                    android:src="@drawable/skin_tabbar_icon_space_select" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom|center"
                    android:text="@string/skin_tabbar_icon_space"
                    android:textColor="@android:color/black"
                    android:textSize="12sp" />
            </FrameLayout>

            <!-- 玩吧 -->

            <FrameLayout
                android:id="@+id/layout_more"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1" >

                <ImageView
                    android:id="@+id/image_more"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="top|center"
                    android:src="@drawable/skin_tabbar_icon_more_select" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom|center"
                    android:text="@string/skin_tabbar_icon_more"
                    android:textColor="@android:color/black"
                    android:textSize="12sp" />
            </FrameLayout>
         </LinearLayout>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="1px"
            android:background="@android:color/black" >
        </LinearLayout>
     </FrameLayout>
    <!-- 中间按钮背景 -->

    <ImageView
        android:id="@+id/toggle_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignTop="@+id/frameMenu"
        android:layout_centerInParent="true"
        android:src="@drawable/skin_tabbar_btn"/>

    <!-- 中间按钮 -->

    <ImageView
        android:id="@+id/plus_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignTop="@+id/frameMenu"
        android:layout_centerInParent="true"
        android:src="@drawable/skin_tabbar_icon_select" />

</RelativeLayout>

【结构图】

时间: 2024-08-28 16:41:41

android布局学习-使用FrameLayout和LinearLayout制作QQ空间底部导航栏的相关文章

Android基础入门教程——5.2.2 Fragment实例精讲——底部导航栏的实现(方法2)

Android基础入门教程--5.2.2 Fragment实例精讲--底部导航栏的实现(方法2) 标签(空格分隔): Android基础入门教程 本节引言: 上一节中我们使用LinearLayout + TextView实现了底部导航栏的效果,每次点击我们都要重置 所有TextView的状态,然后选中点击的TextView,有点麻烦是吧,接下来我们用另一种方法: RadioGroup + RadioButton来实现我们上一节的效果! 1.一些碎碎念 本节用到的是实现单选效果的RadioButt

Android 布局学习之——Layout(布局)具体解释二(常见布局和布局參数)

 [Android布局学习系列]   1.Android 布局学习之--Layout(布局)具体解释一   2.Android 布局学习之--Layout(布局)具体解释二(常见布局和布局參数)   3.Android 布局学习之--LinearLayout的layout_weight属性   4.Android 布局学习之--LinearLayout属性baselineAligned的作用及baseline    Layout Parameters(布局參数): 在XML文件里,我们常常看到类

Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)

[Android布局学习系列]   1.Android 布局学习之——Layout(布局)详解一   2.Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)   3.Android 布局学习之——LinearLayout的layout_weight属性   4.Android 布局学习之——LinearLayout属性baselineAligned的作用及baseline    Layout Parameters(布局参数): 在XML文件中,我们经常看到类似与lay

Android布局学习——android:gravity和android:layout_gravity的区别

[Android布局学习系列]   1.Android 布局学习之——Layout(布局)详解一   2.Android 布局学习之——Layout(布局)详解二(常见布局和布局参数)   3.Android 布局学习之——LinearLayout的layout_weight属性   4.Android 布局学习之——LinearLayout属性baselineAligned的作用及baseline 1.分别是什么?    android:gravity :        定义了一个对象在X,Y

Android UI-仿微信底部导航栏布局

现在App基本的标配除了侧滑菜单,还有一个就是底部导航栏,常见的聊天工具QQ,微信,购物App都有底部导航栏,用户可以随便切换看不同的内容,说是情怀也好,用户体验也罢.我们开发的主要的还是讲的是如何如何实现其功能,网上实现的方式无外乎两种,一种是使用tabhost进行切换,一种是直接使用Fragment进行切换,底部导航栏的布局有的使用的是线性布局,有的是使用的RadioGroup,本文中是使用fragment+RadioGroup是实现的,看正文吧: 基础布局 其中主要低 底部导航栏,其他都没

Android实习札记(5)---Fragment之底部导航栏的实现

Android实习札记(5)---Fragment之底部导航栏的实现 --转载请注明出处:coder-pig 在Part 4我们回顾了一下Fragment的基本概念,在本节中我们就来学习Fragment应用的简单例子吧! 就是使用Fragment来实现简单的底部导航栏,先贴下效果图: 看上去很简单,实现起来也是很简单的哈!那么接着下来就看下实现的流程图吧: 实现流程图: 看完流程图是不是有大概的思路了,那么接着就开始代码的编写吧: 代码实现: ①先写布局,布局的话很简单,一个FrameLayou

Android基础入门教程——5.2.1 Fragment实例精讲——底部导航栏的实现(方法1)

Android基础入门教程--5.2.1 Fragment实例精讲--底部导航栏的实现(方法1) 标签(空格分隔): Android基础入门教程 本节引言: 在上一节中我们对Fragment进行了一个初步的了解,学习了概念,生命周期,Fragment管理与 Fragment事务,以及动态与静态加载Fragment.从本节开始我们会讲解一些Fragment在实际开发 中的一些实例!而本节给大家讲解的是底部导航栏的实现!而基本的底部导航栏方法有很多种, 比如全用TextView做,或者用RadioB

Android应用底部导航栏(选项卡)实例

现在很多android的应用都采用底部导航栏的功能,这样可以使得用户在使用过程中随意切换不同的页面,现在我采用TabHost组件来自定义一个底部的导航栏的功能. 我们先看下该demo实例的框架图: 其中各个类的作用以及资源文件就不详细解释了,还有资源图片(在该Demo中借用了其它应用程序的资源图片)也不提供了,大家可以自行更换自己需要的资源图片.直接上各个布局文件或各个类的代码: [1]  res/layout目录下的 maintabs.xml 源码: <?xml version="1.0

FragmentTabHost+FrameLayout实现底部导航栏

app经常用到底部导航栏,早前使用过RadioGroup+FrameLayout实现或者RadioGroup+ViewPager实现,现在基本使用FragmentTabHost+FrameLayout来实现,因为使用起来简单易用.下面写一个小例子简要地总结一下这个组合. 首先,看一下例子的最终运行效果图 -> 这5个图标的效果其实都是一样的,只要做出来一个,以此类推就可以写出其他几个 第一步, FragmentTabHost+FrameLayout布局,先看一下代码: <?xml versio