2012-12-17 17 views
0

這裏是我的代碼:Android的佈局父權Visiblitiy顯示錯誤

<ProgressBar 
    android:id="@+id/progressBar_main" 
    style="?android:attr/progressBarStyleLarge" 
    android:layout_width="30dip" 
    android:layout_height="30dip" 
    android:layout_marginRight="8dip" 
    android:layout_marginTop="8dip" 
    android:layout_alignParentRight="true" 
    android:visibility="gone"/> 

<ImageView 
    android:id="@+id/iv_broadcast" 
    android:layout_width="45dip" 
    android:layout_height="45dip" 
    android:layout_marginRight="3dip" 
    android:layout_marginTop="1dip" 
    android:layout_toLeftOf="@+id/progressBar_main" 
    android:scaleType="fitXY"/> 

enter image description here

正確的圖像圖像1和圖像2,實際輸出圖像1和圖像3。
當應用程序正在加載數據時,加載欄將設置爲VISIBLE,並且圖像正確顯示爲image1。當加載過程結束時,加載欄將設置爲GONE,它應顯示image2,但它顯示爲image3,這是錯誤的。
如何設置糾正一個(image1 + image2),而不是(image1 + image3)。我不知道爲什麼笑臉會左轉。由於

+0

由於Android的:layout_toLeftOf =「@ + ID/progressBar_main」走了這麼.. – Nikhil

回答

-1

使用該代碼的ImageView

<ImageView 
    android:id="@+id/iv_broadcast" 
    android:layout_width="45dip" 
    android:layout_height="45dip" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="3dip" 
    android:layout_marginTop="1dip" 
    android:layout_toLeftOf="@+id/progressBar_main" 
    android:scaleType="fitXY" /> 
+0

我愛準備您的意見,如果它會爲你工作 –

+0

也不行,重疊的ImageView和加載欄 – jjLin

+0

同時添加的ImageView和進度在線性佈局(這是一個水平方向),所以當你設置progressBar的可見性消失時,imageview自動向右移動 –

-1

給予機器人:layout_alignParentRight = 「true」 以兩個進度和ImageView的。

+0

不好,重疊圖像視圖和加載條 – jjLin