2013-03-26 51 views
0

我試圖把我的ProgressBar放在TableLayout的ontop上。TableLayout的ProgressBar ontop

代碼:

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

<ProgressBar 
    android:id="@+id/bar_Update" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:padding="250dp" 
    android:visibility="visible" /> 

<ScrollView 
    android:id="@+id/ScrollView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

<TableLayout  
    android:id="@+id/tableLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:shrinkColumns="*" 
    android:stretchColumns="*" 
    android:gravity="center_horizontal" 
    android:layout_gravity="top">  

     <TableRow 
      android:id="@+id/RowTitle" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"> 

     <TextView 
      android:id="@+id/Title" 
      android:layout_width="fill_parent" 
      android:layout_height="60px" 
      android:gravity="center" 
      android:text="Unterichtsausfall: \n" 
      android:textSize="20dp" 
      android:textStyle="bold" 
      android:typeface="serif" > 
     </TextView> 

     <ImageView 
      android:id="@+id/imgUpdate" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:adjustViewBounds="false" 
      android:baselineAlignBottom="false" 
      android:clickable="true" 
      android:src="@drawable/refresh" /> 

    </TableRow> 

</TableLayout> 
</ScrollView> 

</LinearLayout> 

進出口使用setVisibility(View.VISIBLE)在我的代碼,以顯示在頂部的佈局進度,但它不工作。爲了顯示它,我使用setVisibility(View.INVISIBLE)。我究竟做錯了什麼? 我的目標是從互聯網上獲取數據。在這段時間,Spinner正在展示。只要數據被提取,它就會顯示在表格中,並且微調不在。

謝謝!

+0

也許你不應該爲所有方向定義填充。這個關於android可見性的鏈接可以幫助你:http://developer.android.com/reference/android/view/View.html#attr_android:visibility – 2013-03-27 03:01:04

回答

1

「On Top」和「Above」之間存在細微差異。 'On Top'通常意味着它覆蓋了下面的圖形,正如人們通常想用ProgressBar所做的那樣。

'高於',通常意味着屏幕頂部較高,這樣ScrollView和TableLayout就會更靠近屏幕的底部。

如果你的ProgressBar是'On Top',那麼View.INVISIBLE就可以。但是,您的ProgressBar在下面的佈局上方。因此,按照您實施的方式,您應該將其設置爲View.GONE以隱藏它。


如果你想顯示進度條「在最前」,還是「過度」低於你的佈局,你將不得不作出頂層佈局RelativeLayout而不是LinearLayout


最後,我不明白什麼是錯的。什麼不適用於您的佈局或代碼行爲?