我如何设置tabhost只占用一些最大宽度和高度

我如何设置tabhost只占用一些最大宽度和高度

问题描述:

我想在我的应用程序中添加一个tabhost。到目前为止,我已经完成了部分工作(出于某种原因,内容不会显示出来,但稍后会出现问题)。但是,是否有可能(不添加像另一个3容器和疯狂的保证金)以确保tabhost不会占用屏幕上的太多空间,或者除非使用边距,否则必须占用整个屏幕我如何设置tabhost只占用一些最大宽度和高度

目前的方式我有它

| _ __ _ __ _ __ _ __ _ __ _ ___
|头
|的TabBar
| tabcontent
| tabcontent
|
__ _ __ _ __ _ __ _ __ _ __ _ _

但中心

的方式我想它

| _ __ _ __ _ __ _ __ _ __ _ ___
|头
|的TabBar           | a pic
| tabcontent     | a pic
| tabcontent     |照片
|
__ _ __ _ __ _ __ _ __ _ __ _ _

塔一峰只是一个画面,占用右侧

整个空间

就像这可能只是操纵tabhost?或者是tabhost全屏幕的东西。

我想通了。之前我的xml有一些奇怪的工作,但这是可能的。我使用的是LinearLayout,右边的图片其权重为1.然后下面是我如何设置tabhost以允许它仅包含其内容的高度和宽度。

<TabHost 
      android:id="@android:id/tabhost" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top" 
      android:layout_marginTop="125dp" > 

      <LinearLayout 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:layout_gravity="center_vertical" 
       android:orientation="vertical" > 

       <TabWidget 
        android:id="@android:id/tabs" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_horizontal" > 

       </TabWidget> 

       <FrameLayout 
        android:id="@android:id/tabcontent" 
        android:layout_width="match_parent" 
        android:layout_height="0dp" 
        android:visibility="gone" /> 

       <FrameLayout 
        android:id="@+android:id/realtabcontent" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" /> 

      </LinearLayout> 
     </TabHost> 

这对我有效,希望它能帮助别人。