0

I'm using a ImageView with a fixed size for adding an icon to a menu. In my application, I use it a lot of times, but on this ImageView the Layout Params seem to not work. Unlike the others ImageViews, in this case, I'm using a template directly, but I think that's not the problem.

<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="1dp"
    android:layout_height="1dp"
    android:scaleType="fitCenter"
    android:src="@drawable/ic_menu_moreoverflow_normal_holo_dark"
    android:contentDescription="ICON" />

Its been used in code as follows.

ImageView iview =(ImageView) View.inflate(context, R.layout.icon, null);

Theoretically, It should resize automatically the image, however, the images continues with the original size, although the size was 1dp. Where is the problem? Thanks a lot!

enter image description here

Laksh
  • 6,717
  • 6
  • 33
  • 34
jramirez
  • 486
  • 9
  • 24

2 Answers2

0
android:scaleType="fitCenter"

you should remove it.

Blackbelt
  • 156,034
  • 29
  • 297
  • 305
0

Change the ImageView assignment of the resource from src to background.

dubmojo
  • 6,660
  • 8
  • 41
  • 68