左右huadong

<?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:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >


        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" >


            <HorizontalScrollView
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_toLeftOf="@+id/next_button"
                android:layout_toRightOf="@+id/up_button"
                android:fillViewport="true"
                android:scrollbars="none" >


                <TabWidget
                    android:id="@android:id/tabs"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content" />
            </HorizontalScrollView>
        </RelativeLayout>


        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" >


            <TextView
                android:id="@+id/textview01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/hello" />


            <TextView
                android:id="@+id/textview02"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/hello" />


            <TextView
                android:id="@+id/textview03"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/hello" />


            <TextView
                android:id="@+id/textview04"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/hello" />


            <TextView
                android:id="@+id/textview05"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/hello" />
        </FrameLayout>
    </LinearLayout>


</TabHost>



package com.gan;




import android.app.TabActivity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TabWidget;


public class HuaDongTabActivity extends TabActivity {
TabHost m_TabHost;
Button upButton;
Button nextButton;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Init
initView();
initTabHost();


// Get scream width
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int screenWidth = dm.widthPixels;
Log.i("test", "screenWidth=" + screenWidth);

// Get tab counts
TabWidget tabWidget = m_TabHost.getTabWidget();
int count = tabWidget.getChildCount();
if (count > 3) {
for (int i = 0; i < count; i++) {
tabWidget.getChildTabViewAt(i).setMinimumWidth((screenWidth) / 3);
}
}
}


private void initView() {
m_TabHost = getTabHost();
// upButton = (Button) findViewById(R.id.up_button);
// nextButton = (Button) findViewById(R.id.next_button);
}


private void initTabHost() {
m_TabHost.addTab(m_TabHost.newTabSpec(0 + "").setIndicator("A  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(1 + "").setIndicator("B  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(2 + "").setIndicator("C  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(3 + "").setIndicator("D  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(4 + "").setIndicator("E  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(5 + "").setIndicator("F  eoe")
.setContent(R.id.textview01));
m_TabHost.addTab(m_TabHost.newTabSpec(6 + "").setIndicator("G  eoe")
.setContent(R.id.textview01));
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值