2013-03-26 50 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


最后,我不明白什么是错的。什么不适用于您的布局或代码行为?