2016-06-08 116 views
2

我有這種佈局,它有一個圓形進度條,但不顯示。我拿上代碼: https://stackoverflow.com/a/5261727/2995941Android:用圓形進度條佈局浮動元素順序

enter image description here

這是我的佈局XML:不顯示

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="pidaas.vicomtech.org.facerec.MainActivity"> 


<SurfaceView 
    android:id="@+id/surfaceView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    /> 

<ImageView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/imageView" 
    android:layout_centerHorizontal="true" 
    android:src="@drawable/calibration_head_b" /> 

<android.support.design.widget.FloatingActionButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Process" 
    android:src="@drawable/unlock" 
    android:id="@+id/process_act" 
    android:layout_alignTop="@+id/photo_act" 
    android:layout_toRightOf="@+id/photo_act" 
    android:layout_toEndOf="@+id/photo_act" 
    android:layout_marginLeft="63dp" 
    android:layout_marginStart="63dp" /> 


<android.support.design.widget.FloatingActionButton 
    android:id="@+id/photo_act" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:clickable="true" 
    android:src="@drawable/icon_camera_128" 
    app:layout_anchorGravity="bottom|right|end" 
    android:layout_marginBottom="55dp" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_marginLeft="103dp" 
    android:layout_marginStart="103dp" /> 

<ProgressBar android:indeterminate="true" 
    android:layout_width="50dp" android:layout_height="50dp" 
    android:id="@+id/marker_progress" style="?android:attr/progressBarStyle" 
    android:layout_gravity="center_vertical|center_horizontal"/> 

</RelativeLayout> 

進度條,這是爲了把這個進度喜歡浮動元素? 可能是android版本沒有采取style?android:attr/progressBarStyle?

我的Android版本支持這些是:

  • com.android.support:appcompat-v7:23.2.1

  • com.android.support:design:23.2.1

在此先感謝。

回答

3

我解決了我的問題:

問題出在進度條元素上。

訂單被正確放置。 我添加了一個背景屬性,android:background =「@ null」,現在我可以在中心看到。

這是最終的xml文件。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    tools:context="pidaas.vicomtech.org.facerec.MainActivity"> 


    <SurfaceView 
     android:id="@+id/surfaceView" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     /> 

    <ImageView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/imageView" 
     android:layout_centerHorizontal="true" 
     android:src="@drawable/calibration_head_b" /> 

    <android.support.design.widget.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Process" 
     android:src="@drawable/unlock" 
     android:id="@+id/process_act" 
     android:layout_alignTop="@+id/photo_act" 
     android:layout_toRightOf="@+id/photo_act" 
     android:layout_toEndOf="@+id/photo_act" 
     android:layout_marginLeft="63dp" 
     android:layout_marginStart="63dp" /> 


    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/photo_act" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:clickable="true" 
     android:src="@drawable/icon_camera_128" 
     app:layout_anchorGravity="bottom|right|end" 
     android:layout_marginBottom="55dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginLeft="103dp" 
     android:layout_marginStart="103dp" /> 


    <ProgressBar android:indeterminate="true" 
     android:layout_width="100dp" android:layout_height="100dp" 
     android:id="@+id/marker_progress" style="?android:attr/progressBarStyle" 
     android:visibility="visible" 
     android:foregroundGravity="center_horizontal" 
     android:background="@null" 
     android:layout_centerVertical="true" 
     android:layout_centerHorizontal="true" /> 
</RelativeLayout>