2012-07-09 69 views
1

我有這樣一個佈局:Android如何防止scrollview的內容跳轉時調整scrollview的大小?

<TableRow 
     android:id="@+id/TabHidden" 
     android:layout_width="fill_parent" 
     android:layout_height="45dp" 
     android:background="@drawable/bg_detail_tab1" 
     android:paddingLeft="5dip" 
     android:paddingRight="5dip" 
     android:paddingTop="10dip" 
     android:visibility="gone" 
    > 
     ... 
</TableRow> 
<ScrollView 
    android:id="@+id/ScrollViewGameDetail" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#ffffff" 
    android:fillViewport="true" > 
    <TableRow 
     android:id="@+id/Tab" 
     android:layout_width="fill_parent" 
     android:layout_height="45dp" 
     android:background="@drawable/bg_detail_tab1" 
     android:paddingLeft="5dip" 
     android:paddingRight="5dip" 
     android:paddingTop="10dip" 
    > 
     ... 
    </TableRow> 
    ... 
</ScrollView> 

當我滾動了滾動到屏幕的頂部,我會躲在裏面滾動型的的TableRow,並通過調用

tabHidden.setVisibility(TableRow.VISIBLE); 
tab.setVisibility(TableRow.GONE); 

這將外面顯示的TableRow使ScrollView外的TableRow始終位於屏幕頂部。除了當TableRow裏面隱藏時,它的工作正常,ScrollView內的所有內容將被推高一點(等於TableRow的高度)。我不想讓它跳起來,因爲滾動動作看起來不順暢。無論如何,以防止ScrollView內容自動填充這樣的空白空間嗎?

回答

1

當您使用setVisibility(View.GONE);將完全刪除,你想爲了留下的空白那裏做什麼,就是用setVisibility(View.INVISIBLE);

+0

我已經嘗試。這在某種程度上是對的,但不幸的是我的情況並非如此。但我會將其設置爲答案,因爲我的問題非常複雜。謝謝。 – user1417127 2012-07-09 09:50:29

+0

好吧,如果您有任何想法,請在此處填寫,我會盡力幫助您。 – Carnal 2012-07-09 09:53:43