Skip to content Skip to sidebar Skip to footer

Am I Supposed To Make Images Larger For Tablets, Or Same Size As Handset?

I am trying to wrap my head around the idea of scaling images which is all new to me. I finally understand for icon launcher you want something like 48x48 for mdpi and 72x72 for hd

Solution 1:

Do you want the images to scale? Or do you want them to stay a particular size.

If you want them to scale, you can use something like this in your layout

    android:adjustViewBounds="true"

Then set your size however you want with either layout_width or maxWidth (and length respectively).

Then scale how you want to:

    android:scaleType="centerInside"

If the images are pixelated, then you need to add larger images for each screen size under your res folder.

Solution 2:

Create a different layout for 10 inches tablet and another for 7 inches tablet then use this code below:

DisplayMetricsdm=newDisplayMetrics();
            getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);

            finalintheight= dm.heightPixels;
            finalintwidth= dm.widthPixels;

          if ((height == 1280) && (width == 800)) {
                        setContentView(R.layout.10inchLayout);
                    }elseif ((height== 1024) && (width == 600)) {
                    setContentView(R.layout.7inchLayout);
                }

                 else {
                    setContentView(R.layout.PhoneinchLayout);
                }

Hope it helps you.

Post a Comment for "Am I Supposed To Make Images Larger For Tablets, Or Same Size As Handset?"