Android 中的水平不确定进度条
Horizontal Indeterminate Progress Bar in Android
我需要在我的 Android 应用程序中创建一个水平进度条。它在一个 phone 上运行良好,但在另一个 phone 上运行不正常。
在 Samsung phones 上,它按预期工作,但在 Nexus phones 上,进度条非常拉伸,看起来不像进度条。
我不确定问题出在哪里。
我的 xml 如下所示:
<ProgressBar
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/background_progress_indicator"
android:layout_weight="0.2"
style="@android:style/Widget.ProgressBar.Horizontal"
android:indeterminate="true"
android:indeterminateDrawable="@anim/progressbar_sync"
/>
progressbar_sync:
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/indeterminate1" android:duration="200" />
<item android:drawable="@drawable/indeterminate2" android:duration="200" />
<item android:drawable="@drawable/indeterminate3" android:duration="200" />
</animation-list>
这两款手机都使用内部 android 库中的进度条小部件样式。
我的猜测是每个 android 库的样式都不同,因为它们是不同品牌的手机
我会尝试使用外部库
这是一个好的开始
https://github.com/castorflex/SmoothProgressBar
我需要在我的 Android 应用程序中创建一个水平进度条。它在一个 phone 上运行良好,但在另一个 phone 上运行不正常。
在 Samsung phones 上,它按预期工作,但在 Nexus phones 上,进度条非常拉伸,看起来不像进度条。
我不确定问题出在哪里。
我的 xml 如下所示:
<ProgressBar
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="@+id/background_progress_indicator"
android:layout_weight="0.2"
style="@android:style/Widget.ProgressBar.Horizontal"
android:indeterminate="true"
android:indeterminateDrawable="@anim/progressbar_sync"
/>
progressbar_sync:
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/indeterminate1" android:duration="200" />
<item android:drawable="@drawable/indeterminate2" android:duration="200" />
<item android:drawable="@drawable/indeterminate3" android:duration="200" />
</animation-list>
这两款手机都使用内部 android 库中的进度条小部件样式。 我的猜测是每个 android 库的样式都不同,因为它们是不同品牌的手机
我会尝试使用外部库 这是一个好的开始 https://github.com/castorflex/SmoothProgressBar