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

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

Android簡單實現(xiàn)屏幕下方Tab菜單的方法

2019-12-12 05:37:20
字體:
來源:轉載
供稿:網友

本文實例講述了Android簡單實現(xiàn)屏幕下方Tab菜單的方法。分享給大家供大家參考,具體如下:

看到很多熱門的Android程序(如:新浪微博、騰訊微博、京東商城、淘寶、當當?shù)鹊龋┦褂眠x項卡風格作為程序界面的主框架結構,而Android的選項卡控件默認是按鈕在上方的。我在網上看到有多種實現(xiàn)方法,這里提供一種個人覺得比較簡單的。由于我對Android開發(fā)所知甚少,方法的優(yōu)劣目前不好評價,歡迎各位提供更好的思路。

主要原理:設置 TabWidget 控件的 android:layout_alignParentBottom="true" 實現(xiàn)。

main.xml:

<?xml version="1.0" encoding="utf-8"?><TabHost android:id="@+id/tabhost" xmlns:android="http://schemas.android.com/apk/res/android"  android:orientation="vertical" android:layout_width="fill_parent"  android:layout_height="fill_parent">  <RelativeLayout android:orientation="vertical"    android:layout_width="fill_parent" android:layout_height="fill_parent">    <TabWidget android:id="@android:id/tabs"      android:layout_width="fill_parent" android:layout_height="wrap_content"      android:layout_alignParentBottom="true" />    <FrameLayout android:id="@android:id/tabcontent"      android:layout_width="fill_parent" android:layout_height="fill_parent">      <LinearLayout android:id="@+id/tab1"        android:layout_width="fill_parent" android:layout_height="fill_parent"        androidrientation="vertical">        <TextView android:id="@+id/view1" android:layout_width="wrap_content"          android:layout_height="wrap_content" android:text="@string/textView_1" />      </LinearLayout>      <LinearLayout android:id="@+id/tab2"        android:layout_width="fill_parent" android:layout_height="fill_parent"        androidrientation="vertical">        <TextView android:id="@+id/view2" android:layout_width="wrap_content"          android:layout_height="wrap_content" android:text="@string/textView_2" />      </LinearLayout>      <LinearLayout android:id="@+id/tab3"        android:layout_width="fill_parent" android:layout_height="fill_parent"        androidrientation="vertical">        <TextView android:id="@+id/view3" android:layout_width="wrap_content"          android:layout_height="wrap_content" android:text="@string/textView_3" />      </LinearLayout>      <LinearLayout android:id="@+id/tab4"        android:layout_width="fill_parent" android:layout_height="fill_parent"        androidrientation="vertical">        <TextView android:id="@+id/view4" android:layout_width="wrap_content"          android:layout_height="wrap_content" android:text="@string/textView_4" />      </LinearLayout>    </FrameLayout>  </RelativeLayout></TabHost>

zhnews.java:

package net.zhnews.android;import android.app.Activity;import android.os.Bundle;import android.widget.TabHost;public class zhnews extends Activity {  /** Called when the activity is first created. */  @Override  public void onCreate(Bundle icicle) {    super.onCreate(icicle);    setContentView(R.layout.main);    setTitle("珠海新聞網Android客戶端");    TabHost tabs = (TabHost) findViewById(R.id.tabhost);    tabs.setup();    TabHost.TabSpec spec = tabs.newTabSpec("tab1");    spec.setContent(R.id.tab1);    spec.setIndicator("新聞");    tabs.addTab(spec);    spec = tabs.newTabSpec("tab2");    spec.setContent(R.id.tab2);    spec.setIndicator("搜聯(lián)社");    tabs.addTab(spec);    spec = tabs.newTabSpec("tab3");    spec.setContent(R.id.tab3);    spec.setIndicator("影像");    tabs.addTab(spec);    spec = tabs.newTabSpec("tab4");    spec.setContent(R.id.tab4);    spec.setIndicator("設置");    tabs.addTab(spec);    tabs.setCurrentTab(0);  }}

更多關于Android相關內容感興趣的讀者可查看本站專題:《Android多媒體操作技巧匯總(音頻,視頻,錄音等)》、《Android開發(fā)入門與進階教程》、《Android視圖View技巧總結》、《Android編程之activity操作技巧總結》、《Android操作SQLite數(shù)據(jù)庫技巧總結》、《Android操作json格式數(shù)據(jù)技巧總結》、《Android數(shù)據(jù)庫操作技巧總結》、《Android文件操作技巧匯總》、《Android編程開發(fā)之SD卡操作方法匯總》、《Android資源操作技巧匯總》及《Android控件用法總結

希望本文所述對大家Android程序設計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 南昌县| 尼玛县| 滦平县| 营山县| 丰原市| 区。| 邯郸市| 青海省| 寻乌县| 合作市| 崇义县| 石渠县| 昆明市| 库尔勒市| 崇仁县| 获嘉县| 贵港市| 巴南区| 玛多县| 南郑县| 玛沁县| 长垣县| 南和县| 和平区| 无极县| 高邑县| 海阳市| 乌兰县| 寻乌县| 宜宾县| 五峰| 河曲县| 天全县| 千阳县| 松原市| 湖州市| 安吉县| 辉南县| 沧源| 太康县| 东源县|