Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
314 views
in Technique[技术] by (71.8m points)

android - ring shapes for L preview not working

Just testing the new developer preview and noticed that my existing ring drawables are not rendering properly. Instead of a ring it's a full circle. Is it a bug or has something changed or am I doing it wrong to begin with? Any possible solutions?

here's the code:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:id="@android:id/progress">
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:thicknessRatio="7.0">
            <solid android:color="#ff5698fb"/>
        </shape>
    </item>
</layer-list>

Thanks!

Update

I've updated the shape as follows:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape
            android:innerRadiusRatio="3"
            android:shape="ring"
            android:thicknessRatio="7.0">
            <solid android:color="#ff5698fb"/>
        </shape>
    </item>
    <item >
        <shape
            android:innerRadiusRatio="4"
            android:shape="ring"
            android:thicknessRatio="5.5">
            <solid android:color="#ffffff"/>
        </shape>
    </item>
</layer-list>

which produces a ring by overlaying two circles. But the progress bar that I'm using it in doesn't work. Here is the code for the progress bar:

<ProgressBar
                android:id="@+id/progressCircle"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:indeterminate="false"
                android:max="100"
                android:progress="65"
                android:rotation="270"
                android:progressDrawable="@drawable/progress_circle"
                android:visibility="visible"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You need to add android:useLevel="true" in the progress item. This didn't seem necessary in previous versions, but L wants it.

<item android:id="@android:id/progress">
    <shape
        android:innerRadiusRatio="3"
        android:shape="ring"
        android:thicknessRatio="7.0"
        android:useLevel="true" >
        <solid android:color="#ff5698fb"/>
    </shape>
</item>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...