2012-08-23 22 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>