Advertisement
Guest User

Untitled

a guest
Jan 29th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class V extends ImageView {
  2.  
  3. private final Matrix matrix;
  4.  
  5. public V(Context context) {
  6. super(context);
  7. matrix = new Matrix();
  8. setScaleType(ScaleType.MATRIX);
  9. }
  10.  
  11. @Override
  12. protected void onSizeChanged(int w, int h, int oldw, int oldh) {
  13. super.onSizeChanged(w, h, oldw, oldh);
  14. Drawable d = getDrawable();
  15. if (d != null) {
  16. float scale = w / (float) d.getIntrinsicWidth();
  17. matrix.postScale(scale, scale);
  18. matrix.postTranslate(0, h - scale * d.getIntrinsicWidth());
  19. setImageMatrix(matrix);
  20. }
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement