0

I am generateing list of app icons at runtime process and storing it in a Drawable object like this:

Drawable d = getPackageManager().getApplicationIcon("package name");
    my_imageView.setImageDrawable(d);
}

It looks perfect in my screen size device (4.5 inch) as I want but when I test it out in larger screen size device like 5,5.5,6 inch screen it looks big. I want it to look same size as it looks in my screen on all screen sizes. Is it possible.Thanks in advance

Here is my xml:

 <ImageView android:layout_height="50dp"
    android:layout_width="50dp"
    android:scaleType="fitXY"
    android:padding="1dp"
    android:layout_alignParentStart="true"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:id="@+id/imageViewicons"/>
Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142
Adarsh
  • 165
  • 2
  • 16

2 Answers2

0

When we talked about supporting different screen size in Android. Everyone is focusing on creating different layouts for every possible screens i.e.

  • ldpi

  • mdpi

  • hdpi

  • xhdpi

  • xxhdpi

  • xxxhdpi

You have to create Different values folder for different screens . Like

values-sw720dp          10.1” tablet 1280x800 mdpi

values-sw600dp          7.0”  tablet 1024x600 mdpi

values-sw480dp          5.4”  480x854 mdpi 
values-sw480dp          5.1”  480x800 mdpi 

values-xhdpi            4.7”   1280x720 xhdpi 
values-xhdpi            4.65”  720x1280 xhdpi 

values-hdpi             4.0” 480x800 hdpi
values-hdpi             3.7” 480x854 hdpi

values-mdpi             3.2” 320x480 mdpi

values-ldpi             3.4” 240x432 ldpi
values-ldpi             3.3” 240x400 ldpi
values-ldpi             2.7” 240x320 ldpi

enter image description here

For More information you can visit here

Community
  • 1
  • 1
Vishal Patoliya ツ
  • 3,170
  • 4
  • 24
  • 45
0

Try putting the object in an android layout as these scale with the size of the screen. but if you want something complex that isnt possible in the layouts you would have to use the Values method.

Just_someone
  • 1,293
  • 1
  • 11
  • 13