Vin*_*oth 44 android android-progressbar
如何在android中显示不确定的水平进度条?进度条的动画应从0到100开始,然后从100连续返回0.我不是在寻找车轮进度条.
Vin*_*oth 45
我已经知道这setIndeterminate将给出一个无限的水平进度条.但它将类似于装载轮,除了它将是水平的.如果你看到我的问题,我正在寻找从0开始的水平条,一直到100(逐渐增加).如果您想在Android中实现此功能,则必须使用以下进度条:
<ProgressBar
android:id="@+id/progress_horizontal"
android:indeterminateOnly="false"
android:indeterminateDrawable="@drawable/progress_indeterminate_horizontal"
android:progressDrawable="@drawable/progress_horizontal"
android:minHeight="24dip"
android:maxHeight="24dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)
由于我想更改进度条的背景,我更改了ProgressDrawable和IndeterminateDrawable.原始的drawables位于frameworks/base/core/res/res/drawable.将它们复制到您的项目并根据您的需要更改颜色.
创建一个更新进度计数的线程并执行Thread.Sleep.然后它将消息发送给Handler,它将更新UI线程中的进度条.
Mic*_*elM 12
使用ProgressBar的方法setIndeterminate:
android.widget.ProgressBar bar = new android.widget.ProgressBar(context);
bar.setIndeterminate(true);
Run Code Online (Sandbox Code Playgroud)
但是,你可以在开发者文档中很快发现这一点.
http://developer.android.com/reference/android/widget/ProgressBar.html#setIndeterminate%28boolean%29
小智 9
要扩展Vinoth Answer,这是一个现成的代码:
<ProgressBar
android:id="@+id/progressBarLoadingRecite"
android:indeterminateDrawable="@android:drawable/progress_indeterminate_horizontal"
android:minHeight="24dip"
android:layout_marginTop="20dip"
android:indeterminate="true"
android:maxHeight="24dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
Run Code Online (Sandbox Code Playgroud)
在定义进度条的 xml 中,您可以添加
style="@android:style/Widget.ProgressBar.Horizontal"
Run Code Online (Sandbox Code Playgroud)
小智 5
也许有些晚,但是您可以执行以下操作:
<ProgressBar
android:id="@+id/progress"
android:layout_width="match_parent"
android:layout_height="10dp"
android:indeterminate="true"
style="?android:attr/progressBarStyleHorizontal" />
Run Code Online (Sandbox Code Playgroud)
希望它能对某人有所帮助!
| 归档时间: |
|
| 查看次数: |
80289 次 |
| 最近记录: |