Android底部的菜单栏实现方法

通常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!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值