具有实心圆的自定义圆形进度条

3

我希望有一个像这样的圆形进度条:

enter image description here

我尝试了一下,但是它不像圆形,而且如何加入动画和渐变效果呢?因为目前我正在为所有六个圆使用相同的XML。

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginRight="15dp"
    android:orientation="vertical" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="vertical" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="72dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="72dp"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_marginLeft="15dp"
    android:orientation="vertical" >

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         android:layout_marginBottom="5dp"
        android:src="@drawable/circle_shape_big_custom_search" />

    <ImageView
        android:layout_width="wrap_content"
         android:layout_marginTop="5dp"
        android:layout_height="wrap_content"
        android:src="@drawable/circle_shape_big_custom_search" />
</LinearLayout>

任何帮助都将不胜感激。

2
请查看:https://github.com/Fichardu/CircleProgress - Haresh Chhelana
这个线程仍然是开放的。有没有人能帮我解决这个问题? - DJhon
1个回答

3

定义进度条,如下代码片段:

<ProgressBar
        android:id="@+id/progress_bar"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:layout_gravity="center"
        android:indeterminateDrawable="@drawable/my_progress_indeterminate"
        android:visibility="gone" >
    </ProgressBar>

my_progress_indeterminate.xml [将此文件放入drawable中]

这是一个XML文件,用于在Android应用程序中创建一个不确定进度条。您需要将此文件放入drawable文件夹中。
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/image_for_rotation"
    android:pivotX="50%"
    android:pivotY="50%" />

将此图片文件放置在drawable目录下: image_to_be_place_in_drawable


毫无疑问,你的答案非常有帮助,但我不想旋转,我想要淡入淡出的动作。这意味着每个圆形图像将保留自己的位置,但它们应该以连续的方式淡入淡出和闪耀。 - DJhon
好的,上述程序几乎实现了您所说的内容,但我认为当旋转速度较慢时,似乎没有进行旋转。 - KOTIOS
是的... 图像应该是静态的,但淡入淡出应该以一种看起来像运动的方式发生。 - DJhon
使用alpha()函数是否可行?我尝试过了,但无法成功实现它。 - DJhon
@BlueGreen 是的:Paint#setAlpha() - pskink
显示剩余2条评论

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