daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Nov 17th, 2018 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. package org.zakky.square;
  3.  
  4. import android.content.Context;
  5. import android.util.AttributeSet;
  6. import android.view.View;
  7.  
  8. public class SquareView extends View {
  9.  
  10.     public SquareView(Context context, AttributeSet attrs, int defStyle) {
  11.         super(context, attrs, defStyle);
  12.     }
  13.  
  14.     public SquareView(Context context, AttributeSet attrs) {
  15.         super(context, attrs);
  16.     }
  17.  
  18.     public SquareView(Context context) {
  19.         super(context);
  20.     }
  21.  
  22.     @Override
  23.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  24.         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  25.  
  26.         int width = MeasureSpec.getSize(widthMeasureSpec);
  27.         int height = MeasureSpec.getSize(heightMeasureSpec);
  28.  
  29.         int smaller = Math.min(width, height);
  30.  
  31.         setMeasuredDimension(smaller, smaller);
  32.     }
  33.  
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top