2013-03-21 22 views
2

我使用TabHost和一個選項卡內,我插入ListView。我將所有高度設置爲fill_parent。但它沒有顯示完整列表,但只是其中的一部分。如何使標籤內容按高度填充屏幕?ListView裏面的tab是不是填充高度?

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

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/bkg" 
     android:orientation="vertical" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="7dp" 
      android:layout_marginRight="7dp" 
      android:layout_marginTop="7dp" 
      android:background="@drawable/gradientrounded" 
      android:orientation="horizontal" > 

      <ImageView 
       android:id="@+id/imageView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="15dp" 
       android:src="@drawable/taxisign" /> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" > 

       <TextView 
        android:id="@+id/taxiprofiletitle" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_marginLeft="15dp" 
        android:layout_weight="0.9" 
        android:text="Large Text" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:textColor="#000000" /> 

       <Button 
        android:id="@+id/phonenumber" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="4dp" 
        android:layout_marginLeft="15dp" 
        android:layout_marginRight="15dp" 
        android:layout_marginTop="5dp" 
        android:background="@drawable/button" 
        android:paddingBottom="5dp" 
        android:paddingTop="5dp" 
        android:text="Button" 
        android:textColor="#ffffff" /> 
      </LinearLayout> 

      <ProgressBar 
       android:id="@+id/loadFeedbacks" 
       style="?android:attr/progressBarStyleLarge" 
       android:layout_width="wrap_content" 
       android:layout_height="0dp" 
       android:layout_gravity="center" 
       android:visibility="invisible" /> 
     </LinearLayout> 

     <TabHost 
      android:id="@android:id/tabhost" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#FFFF0000" > 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical" > 

       <TabWidget 
        android:id="@android:id/tabs" 
        android:layout_width="match_parent" 
        android:background="#FF000000" 
        android:layout_height="wrap_content" > 
        <TextView 
         android:tag="tab0" 
         android:text="Инфо" 
         android:background="@android:drawable/btn_star_big_on" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         /> 
        <TextView 
         android:tag="tab1" 
         android:text="Отзывы" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         /> 
        <TextView 
         android:tag="tab2" 
         android:text="Тарифы" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         /> 
       </TabWidget> 

       <FrameLayout 
        android:id="@android:id/tabcontent" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" > 

        <LinearLayout 
         android:id="@+id/tab1" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" > 

         <TextView 
          android:id="@+id/profile_info" 
          android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="Info" /> 
        </LinearLayout> 

        <LinearLayout 
         android:id="@+id/tab2" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" 
         android:orientation="vertical" > 

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

          <TextView android:text="Добавить" 
           android:layout_width="match_parent" 
           android:layout_height="wrap_content"> 

          </TextView> 
          <ImageButton 
           android:layout_width="wrap_content" 
           android:layout_height="wrap_content"/> 
         </LinearLayout> 
         <ListView 
          android:id="@+id/reviewslist" 
          android:layout_width="match_parent" 
          android:layout_height="wrap_content" > 
         </ListView> 

        </LinearLayout> 

        <LinearLayout 
         android:id="@+id/tab3" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" > 

         <ListView 
          android:id="@+id/tariffslist" 
          android:layout_width="match_parent" 
          android:layout_height="match_parent" 
          android:layout_weight="1" > 
         </ListView> 

        </LinearLayout> 
       </FrameLayout> 
      </LinearLayout> 
     </TabHost> 


    </LinearLayout> 

</ScrollView> 

回答

0

而快速查看XML文件,你的TabHost的(LinearLayout中)的母公司是「WRAP_CONTENT」這似乎讓我不知道,你得到所有的家長。我確實希望有一個更好的UI界面來通過Eclipse構建視覺效果。當他們出現時不太樂意解決這類問題。他們可以經常上來。通常它會涉及一些試驗和錯誤,讓事情看起來像我想要的樣子。

1

在您的第一個LinearLayout更改layout_height="match_parent"。另外,fill_parent自API 8以來已棄用,取而代之的是match_parent,因此您應該使用它。

1

你已經用你的listView高度包裝內容。你應該總是使用高度作爲match_parent/fill_parent。我猜你的問題是在這裏

    <ListView 
         android:id="@+id/reviewslist" 
         android:layout_width="match_parent" 
         android:layout_height="wrap_content" > 
        </ListView> 

將其更改爲:

     <ListView 
         android:id="@+id/reviewslist" 
         android:layout_width="match_parent" 
         android:layout_height="match_parent" > 
        </ListView> 

添加到的是,這種佈局似乎innefcient。不建議使用滾動視圖內的列表視圖。

0

滾動佈局是不必要的,刪除它,使代碼工作

+0

我有這個問題,但需要滾動視圖滾動所有頁面! – sma6871 2015-07-17 18:55:05