2012-03-21 129 views
0

我想諮詢一個xml佈局問題。我有一個主要活動,這是一個TabActivity,它被填充(標籤)由另一個活動,這是一個ListActivity。在scrren和主TabActivity中,我想在頁面底部顯示帶有按鈕的灰色條。問題是該列表視圖的最後一項被該條隱藏。所以我需要的是,該列表視圖應該在按鈕條邊框開始的同一點處具有邊框。它是由圖片瀏覽證實:Android XML佈局覆蓋

http://postimage.org/image/h8yx7jxlj/

我已經試圖改變一些佈局,以WRAP_CONTENT的layout_height參數,但它hasn't幫助...

PS有沒有辦法如何更改標籤標題的字體大小IN XML LAYOUT FILE?

這是主要的活動的我的XML佈局:

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

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


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


</LinearLayout> 

<LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:gravity="center" 
     android:background="#666666"> 

    <Button android:id="@+id/settins_button" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="1sp" 
      android:text="volba zdrojů" 
      android:enabled="false" /> 

</LinearLayout> 

這是被插入的tabcontrol作爲選項卡的內容的活動的XML佈局代碼。 (然後插入的FrameLayout中的tabcontrol的):

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:orientation="vertical" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent"> 

<ListView 
     android:id="@+id/android:list" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"/> 


<TextView 
     android:id="@+id/android:empty" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:gravity="center_vertical|center_horizontal" 
     android:text="@string/main_no_items"/> 

</LinearLayout> 

非常感謝您!

+0

我認爲這個問題是由於有其高度設置爲FILL_PARENT頂部的LinearLayout,而底部的LinearLayout上有重力,使其不佔用房間相比TabHost。嘗試將頂部LinearLayout更改爲wrap_content以獲得高度。 – 2012-03-21 20:55:17

回答

1

請使用RelativeLayout而不是LinearLayout。請參閱附件中的代碼,它完全符合您的要求。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#FFFFFF" > 

    <TextView 
     android:id="@+id/text" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_above="@+id/button" 
     android:layout_alignParentTop="true" 
     android:gravity="center_horizontal" 
     android:text="some text goes here" 
     android:textColor="#1E1E1E" 
     android:textSize="25sp" /> 

    <LinearLayout 
     android:id="@+id/button" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:orientation="horizontal" > 

     <Button 
      android:id="@+id/btn_send" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="15dp" 
      android:layout_marginRight="15dp" 
      android:layout_weight="50" 
      android:onClick="handleSendReport" 
      android:text="@string/button_send" /> 
    </LinearLayout> 

</RelativeLayout>