コード例 #1
0
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
   int height = mDrawable.getIntrinsicHeight() + getPaddingTop() + getPaddingBottom();
   heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
   super.onMeasure(widthMeasureSpec, heightMeasureSpec);
 }
コード例 #2
0
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   final int size = mDrawable.getIntrinsicHeight();
   mDrawable.setBounds(0, 0, size, size);
 }