国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統(tǒng) > Android > 正文

Android編程實(shí)現(xiàn)將ButtonBar放在屏幕底部的方法

2019-12-12 03:32:30
字體:
供稿:網(wǎng)友

本文實(shí)例講述了Android編程實(shí)現(xiàn)將ButtonBar放在屏幕底部的方法。分享給大家供大家參考,具體如下:

前面一篇《Android編程實(shí)現(xiàn)將tab選項(xiàng)卡放在屏幕底部的方法》提到ButtonBar的方式寫底部button,試了試,看起來外觀貌似比Tab好看,不過恐怕沒有Tab管理Activity方便吧,畢竟一 個Tab就是一個Activity,但是這樣用Button的話,卻并不如此,所以這樣的涉及可能雖然好看點(diǎn),但是管理起來卻是相當(dāng)麻煩。那么暫且把對 activity的管理放在一邊,只看界面的設(shè)計(jì)吧。

要涉及這樣的一個buttonbar,主要就是要用到style="@android:style/ButtonBar"這個風(fēng)格。首先還是來看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)于這個的全部代碼了:

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");  }}

如此這般,就形成了下面的這個東西,雖然界面上看起來稍微美觀一點(diǎn),還是上面那句話:管理器Activity不一定很方便哦。

更多關(guān)于Android相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Android開發(fā)入門與進(jìn)階教程》、《Android調(diào)試技巧與常見問題解決方法匯總》、《Android基本組件用法總結(jié)》、《Android視圖View技巧總結(jié)》、《Android布局layout技巧總結(jié)》及《Android控件用法總結(jié)

希望本文所述對大家Android程序設(shè)計(jì)有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 莱芜市| 三河市| 定州市| 泰宁县| 吉隆县| 改则县| 交口县| 报价| 新津县| 班玛县| 长阳| 文水县| 海晏县| 庆阳市| 合水县| 周口市| 方山县| 安仁县| 沁源县| 丽江市| 临湘市| 昔阳县| 龙川县| 鄂托克旗| 康定县| 阿图什市| 鄂州市| 麻江县| 闽侯县| 河北区| 沽源县| 普兰店市| 怀仁县| 韶山市| 会昌县| 涿鹿县| 黑山县| 万安县| 泰顺县| 小金县| 黎川县|