Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class V extends ImageView {
- private final Matrix matrix;
- public V(Context context) {
- super(context);
- matrix = new Matrix();
- setScaleType(ScaleType.MATRIX);
- }
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- Drawable d = getDrawable();
- if (d != null) {
- float scale = w / (float) d.getIntrinsicWidth();
- matrix.postScale(scale, scale);
- matrix.postTranslate(0, h - scale * d.getIntrinsicWidth());
- setImageMatrix(matrix);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement