Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ImageView Nearest Neighbor

I'm creating an app that requires pixel art to be displayed from the web.

On iOS, I can set a UIImageView to have it's magnification filter to

imageView.layer.magnificationFilter = kCAFilterNearest

And everything takes care of itself.

However I cannot seem to do anything about this in Android. How would I change the magnification method of the images that I can hand to Android's imageView?

like image 679
Max Alexander Avatar asked May 22 '16 08:05

Max Alexander


1 Answers

This is done via the BitmapDrawable's Paint, rather than the view, using setFilterBitmap():

myBitmapDrawable.getPaint().setFilterBitmap(false);
myImageView.setImageDrawable(myBitmapDrawable);
like image 71
Martin Stone Avatar answered Oct 23 '22 03:10

Martin Stone