0

Sorry about this post which seems easy, but I don’t understand my problem. I am developing an interface with android studio in xml. I use some PictureButton but I want them to have the same presentation with different devices.

I have put different sizes in folders (hdpi, xhdpi, xxhdpi …) But when I use a device like the nexus 6P I have got this : (Picture 1 - Nexus 6P) and when I use the nexus 10 I’ve got that (Picture 2 - Nexus 10P). The problem is, these devices are in xxhdpi but they haven’t got the same resolution.

For each button I use this xml code :

<ImageButton android:id="@+id/Collecte"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="50dip"
    android:layout_marginLeft="25dip"
    android:background="@android:color/transparent"
    android:src= "@drawable/nouvellecampagne" />

I don’t understand why they are not rescaling.

Cordially

Kamran Ahmed
  • 7,661
  • 4
  • 30
  • 55
Gildas Bng
  • 47
  • 6
  • because of `android:layout_width="wrap_content"` and `android:layout_height="wrap_content"` attributes, android will always display your images in their absolute dimensions, so they'll look smaller in bigger screens. Maybe you can use `LinearLayout` with `layout_weight` to divide the screen in two equally-sized columns and your buttons might look better. Take a look at `ConstraintLayout` and `RecyclerView` too – nandsito Apr 23 '17 at 14:38
  • What is the parent element of your `ImageButton`? Post full XML if possible. – Kamran Ahmed Jun 03 '17 at 11:37

2 Answers2

0

The problem is that you giving hardcore dimen value in width and height in this case image take from hdpi xhdpi anything else but you need to define each and every dimen value in dimen value folder value 21, value small ,value large once you setup i think you can see your best result

and visit:-How to define dimens.xml for every different screen size in android?

0

You should use layout_width="match_parent" and add adjustViewBounds="true" in imageview and let the height to be wrap_content.

parambir singh
  • 224
  • 2
  • 13