此问题的完整解决方案如下。以防万一某人需要代码片段,这就是我所做的。
- 复制所有8不确定的水平进度绘项目
- 编辑使用一些像机械手可绘制并删除不必要的垫衬
- 复制从Android平台
- 复制的风格插件的绘制名为progress_indeterminate_horizontal_holo.xml XML。 ProgressBar.Horizontal及其父母
- 在布局中手动设置样式和min_height
这里是progress_indeterminate_horizontal_holo.xml复制到我的地方风格文件
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/progressbar_indeterminate_holo1" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo2" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo3" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo4" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo5" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo6" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo7" android:duration="50" />
<item android:drawable="@drawable/progressbar_indeterminate_holo8" android:duration="50" />
样式资源。
<style name="Widget">
<item name="android:textAppearance">@android:attr/textAppearance</item>
</style>
<style name="Widget.ProgressBar">
<item name="android:indeterminateOnly">true</item>
<item name="android:indeterminateBehavior">repeat</item>
<item name="android:indeterminateDuration">3500</item>
</style>
<style name="Widget.ProgressBar.Horizontal">
<item name="android:indeterminateOnly">false</item>
<item name="android:indeterminateDrawable">@drawable/progress_indeterminate_horizontal_holo</item>
</style>
最后,在我的本地布局文件中设置最小高度为4dp。
<ProgressBar
android:id="@+id/pb_loading"
style="@style/Widget.ProgressBar.Horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:indeterminate="true"
android:minHeight="4dp"
android:minWidth="48dp"
android:progressDrawable="@drawable/progress_indeterminate_horizontal_holo" />
这对于默认样式的更改有多强大?他们是否保证在所有的永恒中看起来和工作都一样,或者他们在理论上可以随时用替代它们的东西来替代它们,这会导致问题(例如看不见的进度条)。 – Joey
这不适用于所有设备。在Galaxy S6上,即使使用'-6dp'顶部边距,进度条上方的空白仍然可见。 –