有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么选项卡小部件在安卓中位于内容之上?

目前我在做一个tabhost布局

在大多数安卓应用程序中,布局如下:

tab1 | tab 2
____________

Tab 1 content 
(if I press on tab1)

然而,我想要实现的是

Tab 1 content 
(if I press on tab1)
____________
tab1 | tab 2

以下是主要的xml(应用程序的主干):

<LinearLayout
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    安卓:orientation="vertical" >

    <FrameLayout
        安卓:id="@安卓:id/tabcontent"
        安卓:layout_width="0dp"
        安卓:layout_height="0dp"
        安卓:layout_weight="0" />

    <FrameLayout
        安卓:id="@+id/realtabcontent"
        安卓:layout_width="match_parent"
        安卓:layout_height="0dp"
        安卓:layout_weight="1" />

    <TabWidget
        安卓:id="@安卓:id/tabs"
        安卓:layout_width="match_parent"
        安卓:layout_height="wrap_content"
        安卓:layout_weight="0"
        安卓:orientation="horizontal" />
</LinearLayout>

选项卡内容布局

<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
    xmlns:tools="http://schemas.安卓.com/tools"
    安卓:layout_width="match_parent"
    安卓:layout_height="match_parent"
    安卓:background="#31152C"
    安卓:gravity="center"
    tools:context=".MonitoringActivity" >

    <ScrollView
        安卓:layout_width="match_parent"
        安卓:layout_height="wrap_content" >

        <LinearLayout
            安卓:layout_width="match_parent"
            安卓:layout_height="wrap_content"
            安卓:orientation="vertical" >

            <ImageView
                安卓:layout_width="match_parent"
                安卓:layout_height="wrap_content"
                安卓:adjustViewBounds="true"
                安卓:src="@drawable/home" />
        </LinearLayout>
    </ScrollView>

</LinearLayout>

主要课程:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.main);

    ctx = this;

    gs = (MyApp) getApplication();

    tabHost = (FragmentTabHost)findViewById(安卓.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.realtabcontent);

    tabHost.addTab(tabHost.newTabSpec("main").setIndicator(""),Home.class, null);
    tabHost.addTab(tabHost.newTabSpec("carpark").setIndicator("",getResources().getDrawable(R.drawable.btn_park)), CarPark.class,null);
    tabHost.addTab(tabHost.newTabSpec("shop").setIndicator("",getResources().getDrawable(R.drawable.btn_shop)), Shop.class,null);
    tabHost.getTabWidget().setDividerDrawable(null);


    tabHost.setCurrentTab(0);
}

谢谢你的帮助


共 (0) 个答案