android– 自定义进度条中的圆角渐变

android– 自定义进度条中的圆角渐变,第1张

概述你如何在屏幕上为ProgressBar制作圆角渐变?我现在拥有的:pb_shape.xml:<?xmlversion="1.0"encoding="utf-8"?><layer-listxmlns:android="http://schemas.android.com/apkes/android"><itemandroid:id="@android:id/background&q

你如何在屏幕上为Progressbar制作圆角渐变?

我现在拥有的:

pb_shape.xml:

<?xml version="1.0" enCoding="utf-8"?><@R_254_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID"><item androID:ID="@androID:ID/background">    <shape>        <corners androID:radius="12dip" />        <stroke            androID:wIDth="1dip"            androID:color="@color/primary_white" />        <gradIEnt            androID:angle="270"            androID:centercolor="@color/primary_black"            androID:centerY="0.5"            androID:endcolor="@color/primary_black"            androID:startcolor="@color/primary_black"/>        <padding            androID:bottom="4dp"            androID:left="4dp"            androID:right="4dp"            androID:top="4dp" />    </shape></item><item androID:ID="@androID:ID/progress">    <clip>        <shape>            <corners androID:radius="12dip" />            <gradIEnt                androID:angle="0"                androID:endcolor="@color/primary_teal"                androID:startcolor="@color/primary_blue_dark" />                     </shape>    </clip></item>
<Progressbar        androID:ID="@+ID/pb_timer"                androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:progressDrawable="@drawable/pb_shape" />

我已经尝试将androID:gradIEnTradius =“12dip”添加到pb_shape但它不起作用.

解决方法:

好像我找到了一个解决方法,感谢你给@krislarson和this post寻找正确的方向

结果代码:
pb_shape.xml:

<?xml version="1.0" enCoding="utf-8"?><@R_254_3419@ xmlns:androID="http://schemas.androID.com/apk/res/androID"><item androID:ID="@androID:ID/background">    <shape androID:shape="rectangle">        <corners androID:radius="12dip" />        <stroke            androID:wIDth="1dip"            androID:color="@color/primary_white" />        <gradIEnt            androID:angle="270"            androID:centercolor="@color/primary_black"            androID:centerY="0.5"            androID:endcolor="@color/primary_black"            androID:gradIEnTradius="12dip"            androID:startcolor="@color/primary_black" />    </shape></item><item androID:ID="@androID:ID/progress">    <scale        androID:drawable="@drawable/pb_custom_progress"        androID:scaleWIDth="98%" /></item></@R_254_3419@>

pb_custom_progress.xml在这里变得神奇:

<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID"><!--make it rounded--><corners    androID:radius="20dp"    androID:topLefTradius="20dp"    androID:topRighTradius="20dp" /><gradIEnt    androID:angle="0"    androID:endcolor="@color/primary_teal"    androID:startcolor="@color/primary_blue_dark" /><!--create invisible stroke for padding--><stroke    androID:wIDth="6dip"    androID:color="@androID:color/transparent"/></shape>

结果:

总结

以上是内存溢出为你收集整理的android – 自定义进度条中的圆角渐变全部内容,希望文章能够帮你解决android – 自定义进度条中的圆角渐变所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1111083.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存