嘿伙计们,我为我的应用程序创建了这个进度条,但我不能得到那种看起来像红色或蓝色的黄色橙色.
<ProgressBar
android:id="@+id/progress_bar"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="250sp"
android:layout_height="wrap_content"
android:progress="2"
android:layout_marginTop="82dp"
android:max="3"
android:indeterminate="false"
android:layout_below="@+id/imageView"
android:layout_centerHorizontal="true" />
Run Code Online (Sandbox Code Playgroud)
上面是我的进度条xml代码.
有帮助吗?:)
非常感谢提前!:)
the*_*ndr 39
如果Android版本是5.0及以上,你只需要设置
android:indeterminateTint="@color/BLACK"
android:indeterminateTintMode="src_in"
Run Code Online (Sandbox Code Playgroud)
对于较低版本,我使用此
mProgressBar.getIndeterminateDrawable().setColorFilter(getResources()
.getColor(R.color.primary_color),PorterDuff.Mode.SRC_IN);
Run Code Online (Sandbox Code Playgroud)
Vuc*_*cko 11
在drawable文件夹中创建一个名为like的新xml文件custom_progress_bar.xml
并将其粘贴到那里:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Define the background properties like color etc -->
<item android:id="@android:id/background">
<clip>
<shape>
<solid android:color="#000000" />
</shape>
</clip>
</item>
<!-- Define the progress properties like start color, end color etc -->
<item android:id="@android:id/progress">
<clip>
<shape>
<solid android:color="#FFFFFF" />
</shape>
</clip>
</item>
Run Code Online (Sandbox Code Playgroud)
并在您<ProgressBar>
添加此属性:
android:progressDrawable="@drawable/custom_progress_bar"
Run Code Online (Sandbox Code Playgroud)
根据自己的喜好更改2种颜色.我放了#FFFFFF
,#000000
哪个是白色和黑色.
转到您的styles.xml并从您的基本应用程序主题更改colorAccent值,例如
<item name="colorAccent">{COLOR}</item>
我使用的是minSdkVersion 15,它对我有用。
如果您想更改 ProgressBar 颜色,而不是通过 drawable,您可以使用此样式作为 ProgressBar 的主题
<style name="ProgressBar" parent="Widget.AppCompat.ProgressBar">
<item name="colorAccent">@color/white_primary</item>
</style>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
23187 次 |
最近记录: |