Android編程實(shí)現(xiàn)將ButtonBar放在屏幕底部的方法
本文實(shí)例講述了Android編程實(shí)現(xiàn)將ButtonBar放在屏幕底部的方法。分享給大家供大家參考,具體如下:
前面一篇《Android編程實(shí)現(xiàn)將tab選項(xiàng)卡放在屏幕底部的方法》提到ButtonBar的方式寫(xiě)底部button,試了試,看起來(lái)外觀(guān)貌似比Tab好看,不過(guò)恐怕沒(méi)有Tab管理Activity方便吧,畢竟一 個(gè)Tab就是一個(gè)Activity,但是這樣用Button的話(huà),卻并不如此,所以這樣的涉及可能雖然好看點(diǎn),但是管理起來(lái)卻是相當(dāng)麻煩。那么暫且把對(duì) activity的管理放在一邊,只看界面的設(shè)計(jì)吧。
要涉及這樣的一個(gè)buttonbar,主要就是要用到style="@android:style/ButtonBar"這個(gè)風(fēng)格。首先還是來(lái)看xml的設(shè)計(jì),保存layout/bottombtn.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="@+id/textOut"
android:padding="5px" android:layout_weight="1"/>
<LinearLayout style="@android:style/ButtonBar"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:orientation="horizontal">
<Button android:id="@+id/button_weather" android:text="@string/bottom_weather"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/button_mail" android:text="@string/bottom_mail"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/button_train" android:text="@string/bottom_train"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/button_sites" android:text="@string/bottom_sites"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1"/>
<Button android:id="@+id/button_stock" android:text="@string/bottom_stock"
android:layout_width="0dip" android:layout_height="wrap_content"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
然后就是關(guān)于這個(gè)的全部代碼了:
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");
}
}
如此這般,就形成了下面的這個(gè)東西,雖然界面上看起來(lái)稍微美觀(guān)一點(diǎn),還是上面那句話(huà):管理器Activity不一定很方便哦。

更多關(guān)于A(yíng)ndroid相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Android開(kāi)發(fā)入門(mén)與進(jìn)階教程》、《Android調(diào)試技巧與常見(jiàn)問(wèn)題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)》
希望本文所述對(duì)大家Android程序設(shè)計(jì)有所幫助。
- Android動(dòng)態(tài)修改ToolBar的Menu菜單示例
- Android自定義谷歌風(fēng)格ProgressBar
- Android ToolBar整合實(shí)例使用方法詳解
- Android UI控件RatingBar實(shí)現(xiàn)自定義星星評(píng)分效果
- Android編程之ProgressBar圓形進(jìn)度條顏色設(shè)置方法
- Android編程實(shí)現(xiàn)ActionBar的home圖標(biāo)動(dòng)畫(huà)切換效果
- Android判斷NavigationBar是否顯示的方法(獲取屏幕真實(shí)的高度)
- Android編程實(shí)現(xiàn)將tab選項(xiàng)卡放在屏幕底部的方法
- Android6.0 固定屏幕功能實(shí)現(xiàn)方法及實(shí)例
- Android仿淘寶view滑動(dòng)至屏幕頂部會(huì)一直停留在頂部的位置
- Android Animation實(shí)戰(zhàn)之屏幕底部彈出PopupWindow
- android 選項(xiàng)卡(TabHost)如何放置在屏幕的底部
相關(guān)文章
Android開(kāi)發(fā)實(shí)現(xiàn)圓形圖片功能示例
這篇文章主要介紹了Android開(kāi)發(fā)實(shí)現(xiàn)圓形圖片功能,涉及Android實(shí)現(xiàn)圓形圖片的界面布局與CirImageView組件相關(guān)使用操作技巧,需要的朋友可以參考下2019-04-04
Android中控制和禁止ScrollView自動(dòng)滑動(dòng)到底部的方法
這篇文章主要給大家介紹了關(guān)于A(yíng)ndroid中控制和禁止ScrollView自動(dòng)滑動(dòng)到底部的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)各位Android開(kāi)發(fā)者們具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-10-10
獲取Android應(yīng)用專(zhuān)屬緩存存儲(chǔ)目錄的實(shí)例
今天小編就為大家分享一篇獲取Android應(yīng)用專(zhuān)屬緩存存儲(chǔ)目錄的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-08-08
android Watchdog 實(shí)現(xiàn)剖析
Android提供了Watchdog類(lèi),用來(lái)監(jiān)測(cè)Service是否處于正常工作中,是在SystemServer中啟動(dòng)的;本文將詳細(xì)介紹2012-11-11
Android之ArcSlidingHelper制作圓弧滑動(dòng)效果
這篇文章主要介紹了Android之ArcSlidingHelper制作圓弧滑動(dòng)效果,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08
Android ContentProvider查看/讀取手機(jī)聯(lián)系人實(shí)例
本篇文章主要介紹了Android ContentProvider查看/讀取手機(jī)聯(lián)系人實(shí)例,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-02-02
Android ViewPager的MVP架構(gòu)搭建過(guò)程
本文主要介紹了ViewPager在A(yíng)ndroid中的作用以及使用場(chǎng)景,如引導(dǎo)頁(yè)、圖片瀏覽器、新聞或文章內(nèi)容的多標(biāo)簽頁(yè)等,同時(shí),還詳細(xì)闡述了如何通過(guò)MVP架構(gòu)來(lái)搭建ViewPager,將視圖和邏輯進(jìn)行解耦,提高代碼的可測(cè)試性、可復(fù)用性,使代碼結(jié)構(gòu)更清晰且易于擴(kuò)展功能2024-10-10

