目前我在tabhost布局上工作.
在大多数Android应用程序中,布局是:
tab1 | tab 2____________Tab 1 content (if I press on tab1)
但是,我想要实现的目标是
Tab 1 content (if I press on tab1)____________tab1 | tab 2
这是主要的xml(app的主干):
<linearLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:orIEntation="vertical" > <FrameLayout androID:ID="@androID:ID/tabcontent" androID:layout_wIDth="0dp" androID:layout_height="0dp" androID:layout_weight="0" /> <FrameLayout androID:ID="@+ID/realtabcontent" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="1" /> <TabWidget androID:ID="@androID:ID/tabs" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_weight="0" androID:orIEntation="horizontal" /></linearLayout>
选项卡内容布局
<linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:background="#31152C" androID:gravity="center" tools:context=".MonitoringActivity" > <ScrollVIEw androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" > <linearLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:orIEntation="vertical" > <ImageVIEw androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:adjustVIEwBounds="true" androID:src="@drawable/home" /> </linearLayout> </ScrollVIEw></linearLayout>
主要课程:
@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.main); ctx = this; gs = (MyApp) getApplication(); tabHost = (FragmentTabHost)findVIEwByID(androID.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);}
谢谢你的帮助
解决方法:
你可以使用给定的代码将tabWidget添加到底部..
<?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="match_parent" androID:layout_height="match_parent" > <relativeLayout androID:layout_wIDth="match_parent" androID:layout_height="match_parent" > <FrameLayout androID:ID="@androID:ID/tabcontent" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" androID:layout_above="@androID:ID/tabs" /> <TabWidget androID:ID="@androID:ID/tabs" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:layout_alignParentBottom="true" /> </relativeLayout></TabHost>
总结 以上是内存溢出为你收集整理的java – 为什么tab小部件位于android的内容之上?全部内容,希望文章能够帮你解决java – 为什么tab小部件位于android的内容之上?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)