Saturday, 28 September 2013

Center an image in a container scale it and crop the remaining

Center an image in a container scale it and crop the remaining

I have this scenario. So the image is larger than the container

I want it to scale down or scale up depending on the container size but at
the same time put it on the center and crop the remaining (horizontally).
So I did something like this.
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/header_long"
android:gravity="center"
android:antialias="true"
android:dither="true"/>
However it looks like this now. The top, bottom, left and right is cropped.

I want it to be something like this.

No comments:

Post a Comment