2016-11-15 45 views
0

我有一個圖像視圖和一個textView。使圖像視圖看起來在每個設備相同

當我在更大的設備上測試它時,圖像改變了他的位置。

佈局的xml:

<TextView 
    android:id="@+id/monedas_pow" 
    android:text="300" 
    android:textSize="29sp" 
    android:layout_marginLeft="10dp" 
    android:textColor="@color/titlecolor" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    /> 
<ImageView 
    android:id="@+id/summary_btn" 
    android:src="@drawable/coin" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginBottom="525dp" 
    android:layout_toRightOf="@id/monedas_pow" 
    android:layout_marginTop="8dp" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="280dp" /> 

It have to look like this

+0

的[我如何使用複合繪製的,而不是一個包含的ImageView和一個TextView一個的LinearLayout(HTTP可能重複:// stackoverflow.com/questions/8318765/how-do-i-use-a-compound-drawable-instead-of-a-linearlayout-that-c​​ontains-an-imag) –

+0

您必須爲不同的設備創建不同的文件夾,其中包含設備樣式,尺寸等。 – HaroldSer

+0

marginBottom是你有的問題。 –

回答

0

它,因爲你必須在底部和右側巨大的利潤。只是刪除底部和右頁邊距,並添加android:layout_alignBaseline="@+id/monedas_pow" 而且你缺少+在toRightOf所以它添加android:layout_toRightOf="@+id/monedas_pow"

+0

但是,我怎麼能使它在每個設備上工作,而不僅僅是在我的。我是一個begginer –

+0

你在屏幕上的哪個位置試圖放置這些視圖? –

+0

在左上角 –

0

使用的RelativeLayout,在指定align_centerInParent =真正的text_view和使用layout_below =「文本視圖id」你image_view。 例子:

嘗試this..hope它會工作

相關問題