2013-07-02 18 views
1

我有以下佈局:如何將ProgresBar放在我的ImageView前面?

<LinearLayout 
    android:id="@+id/main_ui_container" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@color/red" 
    android:orientation="vertical" > 

    <com.facebook.widget.LoginButton 
     android:id="@+id/login_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     facebook:confirm_logout="false" 
     facebook:fetch_user_info="true" /> 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="0.26" 
     android:src="@drawable/logo" /> 


</LinearLayout> 

我想提出一個ProgresBar在前面(或者頂部,取決於喲怎麼看它)我的ImageView的。

請問我該如何做到這一點?

這是期望的結果:

+1

使用的RelativeLayout代替的LinearLayout的... – Frohnzie

+0

@Frohnzie請我將如何做到這一點? –

回答

4

RelativeLayouts讓項目在彼此的頂部,這是你在找什麼「堆棧」。

因此你可以用你的LinearLayout中的RelativeLayout,和進度添加到相對佈局像這樣:

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

    <LinearLayout 
     android:id="@+id/main_ui_container" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="@color/red" 
     android:orientation="vertical" > 

     <!-- Primary content --> 

    </LinearLayout> 

    <ProgressBar 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" /> 

</RelativeLayout> 
相關問題