2012-08-23 21 views
5

我已经尝试了很多方法来实现下面的例子,但我无法让它工作普遍。如何在按钮周围实现循环进度指示器?

我已经完成建立下面的屏幕。我将右和中心垂直对齐。并给了一些保证金。

enter image description here

我的问题是我必须添加onpressed状态,这和我需要添加像下面的截图圆形的进展。

enter image description here

我不知道如何实现在特定的地方,圆形的进展。我尝试从左中心垂直实施进度,并给了一些保证金并加以修复。但是当我将它安装在大屏幕上时,对齐会出错。所以我试图从右中心垂直实施它,并为此留出了余量。但即使这样也行不通。

请帮助我的人了,怎么解决这个问题:(

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

编辑: 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" /> 
+1

向我们展示您的XML布局文件。 – Elemental

+0

难道你不能把按钮和进度条换成相对布局,然后将它们都设置为居中,这样它们的中间就会始终对齐? – brianestey

+0

嗨@brianestey,谢谢你的回复。我上传的第一张图片是单张图片。我需要将它分开吗?如果是这样,我需要如何分开?我已经将加载和第一个条放置在相对布局中。 –

回答

1

我已经玩过一个示例XML布局,以获得您正在寻找的类似效果。请看这个截图和代码。

Screenshot of the layout

下面粘贴用于实现布局的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>