2012-12-06 18 views
0

我有兩個imageviews我想在RelativeLayout中放置在屏幕上。然而,其中一個圖像的左邊緣在一個部分向左伸出,而其餘部分只是一條直線。我希望其他圖像與線條的直線部分對齊,而不是伸出的額外部分。Android:使用填充或邊距調整視圖錨定通過toLeftOf/toRightOf

不,我不能編輯圖像資源,我不會詳細討論所有細節,我只是說我需要所有的部分。

這裏是什麼,我試圖做一個真正的醜陋形象:

enter image description here

我試過如下:

<ImageView 
    android:id="@+id/block" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignBottom="@+id/interior" 
    android:layout_toLeftOf="@+id/open_wall" 
    android:layout_marginRight="-10dp" 
    android:src="@drawable/block" /> 

但它沒有工作(試過paddingRight)以及。我認爲,因爲該視圖將自己錨定在open_wall圖像的左側,所以如果願意,它不會讓您移動到該分界線之外。

有沒有人有一個想法,我可以做什麼來得到我後?

編輯:根據要求,我想與之合作的圖像:

red(在我的圖中紅色)

black(黑色在我的圖)

+0

你可以張貼的圖片資源?我會看看我能做什麼。 –

+0

圖像已添加到問題,謝謝。 – JMRboosties

回答

0

在這裏你去:

<RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" > 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="51dip" 
     android:src="@drawable/red" /> 

    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:paddingLeft="28dip" 
     android:src="@drawable/black" /> 
</RelativeLayout> 

你所要做的唯一事情是發揮一點與兩個dip值,因爲我不知道哈像你一樣使用相同的分辨率獲取資源。

這是它的樣子:

enter image description here

+0

@jmrboosties它有效嗎? –