Android环形图形的扫描角度动画化

9

尝试将Android Ring Shape动画化,以产生类似于所示序列图像的效果。

Intended Animation

我已经找到了Ring形状的Shape Drawable类型。

<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="ring"
android:innerRadius="75dp"
android:thickness="25dp"
android:useLevel="false">

随着ArcShape(startAngle, sweepAngle)方法的出现。
ShapeDrawable shape = new ShapeDrawable(new ArcShape(0, 360));     
shape.setIntrinsicHeight(100);
shape.setIntrinsicWidth(100);
shape.getPaint().setColor(Color.BLACK);

然而,问题在于找不到可调整绘制形状扫描角度属性或创建ArcShape内半径的能力。
我正尝试制作流畅的动画。
3个回答

5

虽然这是一个旧帖子,但我认为它仍然有用。

我成功地使用上面的代码实现了类似的行为:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape android:shape="oval">
            <size
                android:height="56dp"
                android:width="56dp"/>
            <stroke
                android:width="6dp"
                android:color="#FFFFFF"/>
        </shape>
    </item>
    <item>
        <shape android:shape="oval">
            <size
                android:height="50dp"
                android:width="50dp"/>
            <stroke
                android:width="6dp"
                android:dashGap="140dp"
                android:dashWidth="16dp"
                android:color="#FF0000"/>
        </shape>
    </item>
</layer-list>

关键在于调整dashGap和dashWidth的值,直到获得所需的图像。


1

0

你可以通过不同的起始角度和扫描角度来绘制弧形...以这种方式绘制不同的弧形##

查看图片

ShapeDrawable shapeDrawable=new ShapeDrawable(new ArcShape(220,320));
        shapeDrawable.setIntrinsicHeight(100);
        shapeDrawable.setIntrinsicWidth(100);
        shapeDrawable.getPaint().setColor(Color.RED);
        I1=(ImageView)findViewById(R.id.imageView2);
        I1.setImageDrawable(shapeDrawable);

虽然这可能是答案,但请提供一些关于您的代码的解释,以帮助提问者更好地理解。 - Amir

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接