2013-02-18 23 views
0

我想在我的應用程序中添加一個tabhost。到目前爲止,我已經完成了部分工作(出於某種原因,內容不會顯示出來,但稍後會出現問題)。但是,是否有可能(不添加像另一個3容器和瘋狂的保證金)以確保tabhost不會佔用屏幕上的太多空間,或者除非使用邊距,否則必須佔用整個屏幕我如何設置tabhost只佔用一些最大寬度和高度

目前的方式我有它

| _ __ _ __ _ __ _ __ _ __ _ ___
|頭
|的TabBar
| tabcontent
| tabcontent
|
__ _ __ _ __ _ __ _ __ _ __ _ _

但中心

的方式我想它

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

塔一峯只是一個畫面,佔用右側

整個空間

就像這可能只是操縱tabhost?或者是tabhost全屏幕的東西。

回答

0

我想通了。之前我的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> 

這對我有效,希望它能幫助別人。

相關問題