android设置按钮靠底,Android编程实现将ButtonBar放在屏幕底部的方法

本文实例讲述了Android编程实现将ButtonBar放在屏幕底部的方法。分享给大家供大家参考,具体如下:

前面一篇《Android编程实现将tab选项卡放在屏幕底部的方法》提到ButtonBar的方式写底部button,试了试,看起来外观貌似比Tab好看,不过恐怕没有Tab管理Activity方便吧,毕竟一 个Tab就是一个Activity,但是这样用Button的话,却并不如此,所以这样的涉及可能虽然好看点,但是管理起来却是相当麻烦。那么暂且把对 activity的管理放在一边,只看界面的设计吧。

要涉及这样的一个buttonbar,主要就是要用到style="@android:style/ButtonBar"这个风格。首先还是来看xml的设计,保存layout/bottombtn.xml

android:orientation="vertical" android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:layout_height="wrap_content" android:id="@+id/textOut"

android:padding="5px" android:layout_weight="1"/>

android:layout_width="fill_parent" android:layout_height="wrap_content"

android:orientation="horizontal">

android:layout_width="0dip" android:layout_height="wrap_content"

android:layout_weight="1"/>

android:layout_width="0dip" android:layout_height="wrap_content"

android:layout_weight="1"/>

android:layout_width="0dip" android:layout_height="wrap_content"

android:layout_weight="1"/>

android:layout_width="0dip" android:layout_height="wrap_content"

android:layout_weight="1"/>

android:layout_width="0dip" android:layout_height="wrap_content"

android:layout_weight="1"/>

然后就是关于这个的全部代码了:

package net.wangliping.popup;

import android.app.Activity;

import android.os.Bundle;

import android.widget.TextView;

public class BottomBtn extends Activity {

private static String LOG_TAG = "BottomBtn";

private TextView tv;

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.bottombtn);

tv = (TextView)findViewById(R.id.textOut);

tv.setText("http://tools.wangliping.net");

}

}

如此这般,就形成了下面的这个东西,虽然界面上看起来稍微美观一点,还是上面那句话:管理器Activity不一定很方便哦。

624178a99fe1fe0b71bf19f7244906b3.png

希望本文所述对大家Android程序设计有所帮助。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值