0

I have some image files, which are to be used in Android in ImageViews. Now for MDPI. I created new ImageViews, but the IDE make them smaller than I need, so for MDPI I have a smaller image. How can I return the normal size image? If change manually this file in res/drawable-mdpi, nothing happens, in layout the image is small. Maybe I can somehow delete these resources from all files using it? Why replacing image in res/drawable-mdpi gives nothing?

The first image goes here. Need to add 4 below it.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#45010D">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/radio" />
    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/???" /> // here ??? must be the name of second image and it must be under the first.

    </LinearLayout>
user2543953
  • 123
  • 1
  • 3
  • 11
  • Please add your layout xml code snippet? – Ron Jul 07 '13 at 14:42
  • Yet deleted files in hdpi, xhdpi and xxhdpi folders and copied again. The first image works good. Now I need to paste 5 images each down to previous. How I can do it? If simply paste new ImageView, the sizes change. – user2543953 Jul 07 '13 at 14:46
  • Ok. Add the whole layout file. Difficult to say anything from only the imgview tag – Ron Jul 07 '13 at 14:50

1 Answers1

0

I store all my images in the MDPI directory and then resize them for tablets using code like this:

        if (isTablet(getActivity())){  // tablets only
           debugLog( "display tablet image="+imagename);
           int resID = getResources().getIdentifier(imagename,"drawable", getActivity().getPackageName());                       // the corresponding resource id
           if (resID != 0) {
              Bitmap bmp=BitmapFactory.decodeResource(getResources(), resID);
              int width=480;
              int height=300;
              Bitmap resizedbitmap=Bitmap.createScaledBitmap(bmp, width, height, true);
              ImageView imageView = (ImageView) getActivity().findViewById(R.id.tablet_image);  // the imageview to change
              //imageView.setImageResource(resID);
              imageView.setImageBitmap(resizedbitmap);
           }
        }

Hope this helps.

IanB
  • 3,489
  • 1
  • 20
  • 24
  • Thanks, other resolutions is a further step. Can you advise how to put an image right below the previous with the same alignment and when are stored their aliases? – user2543953 Jul 07 '13 at 14:51
  • Yes, but that is a different question. – IanB Jul 07 '13 at 16:56