如何在按钮周围实现循环进度指示器?

pra*_*mar 5 android android-layout android-progressbar

我已经尝试了很多方法来实现下面的例子,但我不能让它普遍适用.

我已经完成了以下屏幕的构建.我已经对齐右中心和中心垂直.并给予一定的余地.

在此输入图像描述

我的问题是我必须为此添加onpressed状态,我需要添加循环进度,如下面的截图.

在此输入图像描述

我不知道如何在那个特定的地方实施循环进展.我尝试从左中心垂直实现进度并给出一些余量并修复它.但是当我在大屏幕上安装时,校准会出错.所以我尝试从右侧中心垂直实现它,并为该圆圈提供边距.但即使这样也行不通.

请别人帮帮我,如何解决这个问题:(

我被这个打了一个多星期了:(

编辑: XML代码:

<ProgressBar
        android:id="@+id/ProgressBar01"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@drawable/circular_progress"
        android:layout_marginRight="185dp"
        android:progress="50" />

    <ImageButton
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:background="@null"
        android:src="@drawable/tap_to_capture" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="@string/tap_to_cap"
        android:textSize="12sp"
        android:textColor="#006666"
        android:layout_marginRight="25dp"
        android:textAppearance="?android:attr/textAppearanceSmall" />
Run Code Online (Sandbox Code Playgroud)

bri*_*tey 1

我尝试了一个示例 XML 布局以获得与您正在寻找的类似效果。看看这个屏幕截图和代码。

布局的屏幕截图

下面粘贴了实现布局的 XML。显然,您可以随心所欲地设计它。

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

    <RelativeLayout
        android:id="@+id/RelativeLayoutLeftButton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <ProgressBar
            android:id="@+id/progressBar1"
            style="?android:attr/progressBarStyleLarge"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true" />

        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:background="@android:color/transparent"
            android:src="@drawable/ic_play" />
    </RelativeLayout>

    <TextView
        android:id="@+id/textView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_toRightOf="@+id/RelativeLayoutLeftButton"
        android:text="Click Here"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textColor="#006666"
        android:textSize="12sp" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)