title: android custom view onmeasure TextView
body: <p>I tried to do custom component. I extended View class and do some TextView in method override onMeasure?  I've seen couple tutorials, but each one is a little been different. Sometimes they call super.onMeasure at the end, sometimes they use setMeasuredDimension and didn't call it. Where is a difference image and textview in onMeasure size ?</p>
  
  <p>my cod for onmeasure ImageView for SquareImageView</p>
  
  <pre><code>public class SquareImageView extends ImageView {
      public SquareImageView(Context context) {
         super(context);
      }
  
      public SquareImageView(Context context, AttributeSet attrs) {
         super(context, attrs);
     }
  
     public SquareImageView(Context context, AttributeSet attrs, int defStyle) {
         super(context, attrs, defStyle);
     }
  
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
         setMeasuredDimension(getMeasuredWidth(), getMeasuredWidth());
         //Snap to width
     }
  }
  </code></pre>
  
  <p>How can I set dynamic height in <code>TextView</code>?</p>
  
  <pre><code>    &lt;com.SquareImageView
      android:id="@+id/picture"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:scaleType="centerCrop"/&gt;
  </code></pre>