title: Set height and width of custom view according to xml
body: <p>I have successfully made a custom PinView class.
  Now the problem is I want to set the pin view buttons size according to PinView size that is specified in XML. Like a button would have 5% width and height of PinView.</p>
  
  <p>currently, I am setting PinView height and width by doing this <code>getPinPadHeight()</code> is returning 80% of screen height and 70% of screen width</p>
  
  <pre><code>@Override
  protected void onAttachedToWindow() {
      super.onAttachedToWindow();
      pinView.getLayoutParams().height = ViewUtil.getPinPadHeight();
      pinView.getLayoutParams().width = ViewUtil.getPinPadWidth();
  }
  </code></pre>
  
  <p>but now the problem is this when I use this custom PinView view in my main activity XML file like this.</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       xmlns:app="http://schemas.android.com/apk/res-auto"
       xmlns:tools="http://schemas.android.com/tools"
       android:id="@+id/parent_view"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:background="@color/colorPrimary"
       android:orientation="vertical"
       tools:context=".MainActivity"&gt;
  
       &lt;production.kado.lock.views.PinView
           android:id="@+id/pinView"
           android:layout_centerInParent="true"
           android:layout_width="300dp"
           android:layout_height="200dp"
           app:changePassword="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and i want to change its height and width its not changing its always set according to screen height and width percentage how can i make this view like some library so i can  set height and width according to my preference and views inside it automatically measure themselves accroding to xml attributes when I will use this custom view</p>
  
  <pre><code>public class PinView extends RelativeLayout {
      public PinView(Context context) {
          super(context);
          initView();
      }
  
      public PinView(Context context, AttributeSet attrs) {
          super(context, attrs);
  
          initView();
      }
  
      public PinView(Context context, AttributeSet attrs, int defStyle) {
          super(context, attrs, defStyle);
          initView();
      }
  
      @Override
      protected void onAttachedToWindow() {
          super.onAttachedToWindow();
          pinView.getLayoutParams().height = ViewUtil.getPinPadHeight();
          pinView.getLayoutParams().width = ViewUtil.getPinPadWidth();
      }
  }
  </code></pre>