Adjusting images on different screens

Asked

Viewed 197 times

2

I’m running the app on two emulators that have exactly the same resolution but different densities:

  1. 720 x 1280 160dpi
  2. 720 x 1280 320dpi

I want the image to take the same space on the screen. I understand that, using DP, the density becomes indifferent, because the system calculates the amount of pixels according to the density and the space that the image should have on the screen. However, this does not happen:

inserir a descrição da imagem aqui

How to reach this value in PD so that an image takes exactly the same space on screens with different sizes and densities?

XML:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/rl"
    android:layout_width="match_parent"
    android:layout_height="match_parent">


    <ImageView
        android:id="@+id/logo"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:src="@drawable/logo"
        android:layout_centerInParent="true"/>
</RelativeLayout>
  • Post the xml you are using.

  • The image emulators you posted have different resolutions.

  • Actually, I uploaded the wrong image. They have the same resolution as I mentioned. I will edit with XML

1 answer

2

Create images with different resolutions and place in the respective Packages, according to the list below:

  • xlarge (xhdpi): 640x960 (320 dpi)
  • large (hdpi): 480x800 (240 dpi)
  • medium (mdpi): 320x480 (160 dpi)
  • small (ldpi): 240x320 (120 dpi)

Link to documentation

  • So I’ve done it before, but I can’t get to the result. Take a look at my other post to see if you understand the problem better... http://stackoverflow.com/questions/38292713/two-screens-same-size-with-different-density?noredirect=1&lq=1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.