简单小布局,仅供参考

一、布局文件:

<?xml version="1.0" encoding="UTF-8" ?>
 <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent">
  <LinearLayout
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   android:background="@drawable/backgroud">
   <!--标题栏开始 -->
  <LinearLayout
   android:layout_height="wrap_content"
   android:id="@+id/LinearLayout_binding_settings_top"
   android:layout_width="fill_parent"
   android:background="@drawable/bg_title"
   android:gravity="right|center_vertical">
   <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/Button_binding_settings_main"
    android:text="首页" android:textColor="#ffffff"
    android:layout_marginLeft="5dip"
    android:background="@drawable/back_multiplicity_image"/>
   <LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:layout_weight="1"
    android:id="@+id/LinearLayout_binding_settings_title"
    android:gravity="center">
    <TextView
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:id="@+id/TextViewbinding_settings"
     android:text="Fun-Guide"
     android:textColor="#ffffff" android:textSize="28sp"/>
   </LinearLayout>
   <Button
       android:id="@+id/OkButton"
       android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:layout_gravity="center_vertical|right"
        android:layout_marginRight="10dip"
        android:textColor="#ffffff"
        android:text="前进"
        android:background="@drawable/ok_to_previous_multiplicity_image"/>
  </LinearLayout>
  <!--标题栏结束-->
  <FrameLayout
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="0.0dip"
    android:layout_weight="1.0" />
  <TabWidget
   android:id="@android:id/tabs"
    android:visibility="gone"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0.0" /> 
    <RadioGroup
     android:gravity="center_vertical"
     android:layout_gravity="bottom"
     android:orientation="horizontal"
     android:id="@+id/main_radio"
     android:background="@drawable/maintab_toolbar_bg"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content">
     <RadioButton android:id="@+id/radio_button0" android:text="android" android:drawableTop="@drawable/icon_home" style="@style/main_tab_bottom" />
     <RadioButton android:id="@+id/radio_button1" android:text="linux" android:drawableTop="@drawable/icon_meassage" style="@style/main_tab_bottom" />
     <RadioButton android:id="@+id/radio_button2" android:text="oracle" android:drawableTop="@drawable/icon_selfinfo" style="@style/main_tab_bottom" />
     <RadioButton android:id="@+id/radio_button3" android:text="embed" android:drawableTop="@drawable/icon_square" style="@style/main_tab_bottom" />
     <RadioButton android:id="@+id/radio_button4" android:text="more" android:drawableTop="@drawable/icon_more" style="@style/main_tab_bottom" />
    </RadioGroup>
   </LinearLayout>
  </TabHost>
二、res下得几个小文件

例如 back_multiplicity_image.xml

<?xml version="1.0" encoding="utf-8"?>
<selector
  xmlns:android="http://schemas.android.com/apk/res/android"
  >
   
   <!-- 初始状态 -->
   <item
  android:state_pressed="false"
  android:drawable="@drawable/back_to_previous" />
 
 <!-- 按下状态 -->
 <item
  android:state_pressed="true"
  android:drawable="@drawable/back_to_previous_press" />
</selector>
三、主Activity代码

package com.magus.TabActivity;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.CompoundButton;
import android.widget.RadioButton;
import android.widget.TabHost;
import android.widget.CompoundButton.OnCheckedChangeListener;

public class MainActivity extends TabActivity implements OnCheckedChangeListener{
 private TabHost mHost;
 private Intent androidIntent;
 private Intent linuxIntent;
 private Intent oracleIntent;
 private Intent embeddedIntent;
 private Intent moreIntent;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.main);

  // ~~~~~~~~~~~~ 初始化
  
    this.androidIntent = new Intent(this, MainActivity1.class);
    this.linuxIntent = new Intent(this, MainActivity2.class);
    this.oracleIntent = new Intent(this, MainActivity3.class);
    this.embeddedIntent = new Intent(this, MainActivity4.class);
    this.moreIntent = new Intent(this, MainActivity5.class);
  

  initRadios();

  setupIntent();
 }

 
 private void initRadios() {
  ((RadioButton) findViewById(R.id.radio_button0))
    .setOnCheckedChangeListener(this);
  ((RadioButton) findViewById(R.id.radio_button1))
    .setOnCheckedChangeListener(this);
  ((RadioButton) findViewById(R.id.radio_button2))
    .setOnCheckedChangeListener(this);
  ((RadioButton) findViewById(R.id.radio_button3))
    .setOnCheckedChangeListener(this);
  ((RadioButton) findViewById(R.id.radio_button4))
    .setOnCheckedChangeListener(this);
 }

 
 public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  if (isChecked) {
   switch (buttonView.getId()) {
   case R.id.radio_button0:
    this.mHost.setCurrentTabByTag("mblog_tab");
    break;
   case R.id.radio_button1:
    this.mHost.setCurrentTabByTag("message_tab");
    break;
   case R.id.radio_button2:
    this.mHost.setCurrentTabByTag("userinfo_tab");
    break;
   case R.id.radio_button3:
    this.mHost.setCurrentTabByTag("search_tab");
    break;
   case R.id.radio_button4:
    this.mHost.setCurrentTabByTag("more_tab");
    break;
   }
  }
 }

 private void setupIntent() {
  this.mHost = getTabHost();
  TabHost localTabHost = getTabHost();

  if (localTabHost != null) {

   localTabHost.addTab(buildTabSpec("mblog_tab", R.string.menu_android,
     R.drawable.icon_1_n, androidIntent));

   localTabHost.addTab(buildTabSpec("message_tab", R.string.menu_linux,
     R.drawable.icon_2_n, linuxIntent));

   localTabHost.addTab(buildTabSpec("userinfo_tab",
     R.string.menu_oracle, R.drawable.icon_3_n,
     oracleIntent));

   localTabHost.addTab(buildTabSpec("search_tab",
     R.string.menu_embed, R.drawable.icon_4_n,
     embeddedIntent));

   localTabHost.addTab(buildTabSpec("more_tab", R.string.menu_more,
     R.drawable.icon_5_n,moreIntent));
  }
 }

 private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,
   final Intent content) {
  return this.mHost
    .newTabSpec(tag)
    .setIndicator(getString(resLabel),
      getResources().getDrawable(resIcon))
    .setContent(content);
 }
}

四、res values下得东东



dimens.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <dimen name="button_height">45.0dip</dimen>
    <dimen name="bottom_tab_font_size">9.0dip</dimen>
    <dimen name="bottom_tab_padding_up">5.0dip</dimen>
    <dimen name="bottom_tab_padding_drawable">2.0dip</dimen>
    <dimen name="switch_logo_bottom_padding">30.0sp</dimen>
    <dimen name="widget_height">100.0dip</dimen>
    <dimen name="sta_height">48.0dip</dimen>
    <dimen name="widget_write_margin_top">19.0dip</dimen>
    <dimen name="widget_write_margin_left">10.0dip</dimen>
    <dimen name="widget_content_margin_top">20.0dip</dimen>
    <dimen name="widget_content_margin_left">10.0dip</dimen>
    <dimen name="widget_logo_size">35.0dip</dimen>
    <dimen name="title_height">74.0dip</dimen>
    <dimen name="new_blog_size">70.0dip</dimen>
    <dimen name="emotion_item_view_height">13.299988dip</dimen>
    <dimen name="splash_test_center_margin_right">0.0dip</dimen>
    <dimen name="group_item_height">40.0dip</dimen>
    <dimen name="suggestion_item_height">40.0dip</dimen>
    <dimen name="suggestion_item_title_height">16.669983dip</dimen>
    <dimen name="square_item_width">60.0dip</dimen>
    <dimen name="square_padding_left">20.0dip</dimen>
    <dimen name="square_padding_top">8.0dip</dimen>
    <dimen name="square_horizontalSpacing">8.0dip</dimen>
    <dimen name="square_verticalSpacing">0.0dip</dimen>
    <dimen name="square_page_item_padding">3.0dip</dimen>
    <dimen name="square_height">265.0dip</dimen>
    <dimen name="updatebar_height">62.0dip</dimen>
    <dimen name="updatebar_content_height">60.0dip</dimen>
    <dimen name="updatebar_padding">10.0dip</dimen>
    <dimen name="userinfo_center_square_height">113.32999dip</dimen>
    <dimen name="toolbar_height">45.0dip</dimen>
</resources>

strings.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="menu_android">Android</string>
    <string name="menu_linux">Linux</string>
    <string name="menu_oracle">Oracle</string>
    <string name="menu_embed">嵌入式</string>
    <string name="menu_more">更多</string>
    <string name="app_name">尚观客户端</string>
</resources>

styles.xml:

<?xml version="1.0" encoding="UTF-8"?>
<resources>

 <style name="main_tab_bottom">
  <item name="android:textSize">@dimen/bottom_tab_font_size</item>
  <item name="android:textColor">#ffffffff</item>
  <item name="android:ellipsize">marquee</item>
  <item name="android:gravity">center_horizontal</item>
  <item name="android:background">@drawable/home_btn_bg</item>
  <item name="android:paddingTop">@dimen/bottom_tab_padding_up</item>
  <item name="android:layout_width">fill_parent</item>
  <item name="android:layout_height">wrap_content</item>
  <item name="android:button">@null</item>
  <item name="android:singleLine">true</item>
  <item name="android:drawablePadding">@dimen/bottom_tab_padding_drawable</item>
  <item name="android:layout_weight">1.0</item>
 </style>

</resources>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值