Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setScaleType to ScaleType.MATRIX programmatically not work but in xml it work

this is my code :

    LinearLayout imageViewParent = (LinearLayout) findViewById(R.id.imageViewParent);
    ImageView view = new ImageView(this);
    imageViewParent.addView(view);
    view.setScaleType(ScaleType.MATRIX);
    view.setBackgroundResource(R.drawable.np);

In this code scale type to matrix not work(it fix image to parents),but when I implement this in xml it works fine! can every one help me? thank you!

like image 293
ali shekari Avatar asked Sep 23 '13 06:09

ali shekari


1 Answers

You should use setImageResource not setBackgroundResource.

like image 135
Snicolas Avatar answered Nov 15 '22 14:11

Snicolas