2012-06-27 118 views
0

我创建了一个包含水平进度的XML文件,但它显示为如下图所示:水平进度条不显示正确

Progress bar image

这里是我的XML:

<?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:orientation="vertical" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 


    <ProgressBar 
     android:id="@+id/progress" 
     style="@android:style/Widget.ProgressBar.Horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:max="100" 
     android:progress="50" /> 

</LinearLayout> 

发生了什么?我该如何解决它?

+0

你得到你的进度现在的工作?看看我的回答 –

+0

@K_Anas [这里是你的修复结果](http://no6.upanh.com/b5.s28.d3/d92f828109ac5018216887c3680f635a_46596036.capture.png ) – user1465351

+0

尝试添加'android:maxHeight =“12dip”和android: minHeight =“12dip”'进度条。 – Chandra

回答

0

它被卷到你给它

android:layout_width="fill_parent" 
android:layout_height="fill_parent" 

尝试使用WRAP_CONTENT或设置layout_weight大小。另外,您似乎对XML布局没有很好的理解。我建议仔细阅读这篇文章:http://developer.android.com/guide/topics/ui/declaring-layout.html

+0

我尝试它(wrapcontent和fillparent或修复大小),但不工作。我也清理和建立,但它不起作用 – user1465351

+0

我认为我上面的人更好地理解你。 –

1

通常情况下,你应该得到一个horizo​​ntalProgress酒吧与你的布局,但尝试

改变你的风格标签在你的进度窗口小部件此

style="?android:attr/progressBarStyleHorizontal" 


<ProgressBar 
    android:id="@+id/progress" 
    style="?android:attr/progressBarStyleHorizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:max="100" 
    android:progress="50" /> 
+0

我改变了风格,但它不会改变 – user1465351

+0

@ user1465351尝试清除您的项目!或事件重启eclipse,并让我知道 –

-1

你试图添加一个android:indeterminate =“false”到你的XML文件中?你的进度条XML应该是这样的:

<ProgressBar 
    android:id="@+id/progress" 
    style="@android:style/Widget.ProgressBar.Horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:max="100" 
    android:indeterminate="false" 
    android:progress="50" /> 

纺车是“不确定”模式,当总进度不知道(即你只是让用户知道他们需要等待,但你不知道多久)。

0

我建议添加此活动中的文件

pbSurvey.getProgressDrawable().setColorFilter(Color.parseColor("#0668A1"), PorterDuff.Mode.SRC_IN);