【发布时间】:2014-04-14 12:51:21
【问题描述】:
在我的应用程序中,我插入了一个自定义进度条。
问题是没有显示进度。当在我调用setProgress 的代码中时,条形图保持背景颜色。而如果在布局设置中setProgress 正常显示。
在插入自定义工具栏之前,它工作得很好
这是一些代码:
drawable/customprogressbar.xml
<?xml version="1.0" encoding="UTF-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="#5c5c5b"
android:endColor="#9d9d9c"
android:centerY="1"
android:angle="270"
/>
</shape>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners
android:radius="5dip" />
<gradient
android:startColor="#85040b"
android:endColor="#e30613"
android:centerY="1"
android:angle="270"
/>
</shape>
</clip>
</item>
</layer-list>
还有我看到进度条的布局
<ProgressBar
android:id="@+id/progressBar1"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:max="100"
android:progress="50"
android:layout_alignTop="@+id/map"
android:progressDrawable="@drawable/customprogressbar"
android:visibility="visible" />
在我调用的代码中
progresbar.setProgress(progress);
设置进度
【问题讨论】:
-
先明确你的问题什么是有效的?
-
你能告诉我们逻辑吗?
-
你能分享你的代码吗?
-
我试图更好地解释:当我从代码中设置进度时,它不起作用。但是如果我从布局中设置它,它会显示进度。
-
@umerk44 代码的哪一部分?只需调用一个对文件执行操作的异步任务,progressupdate 会更新进度条。我重复一遍,在不改变栏的外观的情况下,它可以工作
标签: android xml progress-bar customization