简体   繁体   中英

Make an image view look the same in every device

I have an image view and a textView.

When i test it in bigger devices, the image changes his position.

layout 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" />

它必须看起来像这样

Its because you have huge margins on bottom and right. Just remove bottom and right margin and add android:layout_alignBaseline="@+id/monedas_pow" And you are missing + in toRightOf so add it android:layout_toRightOf="@+id/monedas_pow"

Use RelativeLayout, in that specify align_centerInParent = true for text_view and use layout_below = "your text view id" to your image_view. Example:

Try this..hope it will work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM