2012-06-04 61 views
0

這是我的佈局XML:Android的佈局 - 圖像查看推離

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/main_screen" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/back" 
    android:baselineAligned="false" 
    android:gravity="center_vertical" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/bottleImageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top" 
     android:layout_margin="10dp" 
     android:src="@drawable/icon_food_milk" /> 

    <ImageView 
     android:id="@+id/diaperImageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top" 
     android:layout_margin="10dp" 
     android:src="@drawable/icon_store_diaper" /> 

    <android.opengl.GLSurfaceView 
     android:id="@+id/glview" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom" 
     android:layout_marginTop="60dp" 
     android:windowIsTranslucent="true" /> 

</LinearLayout> 

在實際應用中的onCreate我躲都imageviews,然後在必要時我告訴他們。但是當我這樣做時,GLSurfaceView將向右移動imageview的寬度。

+0

試試這個:.... android:layout_gravity =「bottom |左「 – MAC

+0

因爲你的父母android:orientation =」horizo​​ntal「將其改爲垂直 –

回答

0

這是因爲,您正在使用LinearLayouthorizontal方向。當您使imageViews可見時,此viewGroup中的所有視圖都會嘗試水平放置。如果您想使位置固定,使用RelativeLayoutalignParentBottom = true

0

你的父母佈局這種情況下是線性的佈局它的方向是

android:orientation="horizontal" 

這將始終處於水平位置

| | 
view1 view2.... 
| | 

改爲`android:orientation =「vertical」

那麼你的視圖應該是

view 1 
view 2 
. 
. 
+0

如果我將它改爲」vertical「,那麼GLSurfaceView向下移動而不是向左移動 – Trick

+1

然後使用相對佈局leftof .. –