这里的两边都是圆角,指的是progressbar的progress部分
比如,需要这个效果:
如果使用shape,progress的右边是直角,所以使用了.9图
但是实际中,设置progress为10了之后(max为100),整体还是很宽,感觉像是progress属性不能用了
原始界面文件中的使用:
<ProgressBar
android:id="@+id/live_channel_progres"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="112dp"
android:layout_height="15dp"
android:max="100"
android:progress="10"
android:progressDrawable="@drawable/progress_bg" />
progress的drawable:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- 背景 gradient是渐变,corners定义的是圆角 -->
<item android:id="@android:id/background">
<shape>
<corners android:radius="30dp" />
<solid android:color="#ff0" />
</shape>
</item>
<!-- 进度条 -->
<item android:id="@android:id/progress" android:drawable="@drawable/live_channel_progress"/>
</layer-list>
Solved. My question may not be clear, causing someone to misunderstand it. The current requirements are:
I tried using shape from the beginning, but it didn’t work
I copied the answer on the first floor and tried it, and the effect was the same as my initial result
If you use the .9 picture, you can avoid this problem, just put the question:
Just change this part:
This is because the Progressbar will clip when drawing. If you specify the clip attribute, the right side will definitely be cut into a right angle, so you need to use scale in the item. It will be perfect with the .9 picture.
http://stackoverflow.com/questions/2078809/progress-bar-rounded-on-both-sides-in-android
style:
progress_validity:
There is a problem with the formatting. Please sort it out yourself. . Correct by personal test.