通常Android底部的菜单栏都是通过继承TabActivity这个类,在底部定义RadioGrou来实现,但进今天我要以另外一种方式来写,采用直接在底部定义TextVIew来实现,它与TabActivity的主要区别在于当单击某一个按钮的时候整个Activity都会跳转,而不是像TabActivity那样只是按钮上面的部分更换,两者各自的作用方向不一样啦~大家各自选择所需吧,TabActivity的使用方法会在后续文章中来写~我是采用Ubuntu进行开发Android项目的。
首先,新建项目,取名TabTextViewTest,编写主Activity的xml布局文件,代码如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
android:background="#000000"
android:baselineAligned="false" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/message"
android:textColor="@android:color/white"
android:drawableTop="@android:drawable/ic_menu_send"
android:layout_gravity="bottom"
android:layout_weight="1"/>
<TextView
android:id="@+id/waitView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/backup"
android:textColor="@android:color/white"
android:drawableTop="@android:drawable/ic_menu_save"
android:layout_gravity="bottom"
android:layout_weight="1"/>
<TextView
android:id="@+id/deallist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/social"
android:textColor="@android:color/white"
android:drawableTop="@android:drawable/ic_menu_share"
android:layout_gravity="bottom"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="@string/more"
android:textColor="@android:color/white"
android:drawableTop="@android:drawable/ic_menu_more"
android:layout_gravity="bottom"
android:layout_weight="1"/>
</LinearLayout>
</RelativeLayout>
主界面Activity的java文件不需要该,最终效果如下:
Enjoy It!
分享到:
相关推荐
android底部菜单栏demo
Android底部菜单栏 简单易懂 比较适合新手学习
android底部菜单栏
NULL 博文链接:https://android-zhang.iteye.com/blog/1485829
Android 使用RadioGroup 实现底部导航菜单栏。 一、主界面布局的实现: 先来张效果图: 介绍一下总体界面包括的内容:底部五个导航按钮,主界面包括一个FrameLayout用来放五个Fragment。点击底部按钮会对应跳转...
用两种不同的方式实现了Android底部菜单栏的效果(也叫Tab选项卡)
仿微信底部菜单栏 底部菜单字体显示隐藏 底部菜单缩放等等
android 底部菜单实现
android底部菜单栏实现源码,参考。
积攒的资源,TabHost实现底部菜单栏的功能
让你五分钟就可以接入fragment的底部菜单栏,或者接入fragment+viewpager的底部菜单栏。
Android Studio 底部自定义菜单,菜单上有消息数提醒,很实用
(1)通过TabWidget实现 (2)隐藏TabWidget,通过RadioGroup和RadioButton实现底部菜单栏
android 应用 底部菜单栏的实现LinearLayout
一个纯代码实现的android底部菜单栏,动态加载,简单实用
使用RadioGroup实现的底部导航菜单栏
Android底部菜单栏显示与隐藏 https://blog.csdn.net/qq_31939617/article/details/80858902
Android 底部菜单栏(RadioGroup+Fragment)美化,文章地址:http://blog.csdn.net/baiyulinlin1/article/details/74990105