title: Custom views in android
body: <p>I just started learning on how to make custom views .I created a drawable at the bottom of the screen and a small circle within it. The layout works perfectly fine but there is a small issue , the drawable in different resolution is cropped . Its works fine in S3 but in other devices the things are different. <img src="https://i.stack.imgur.com/pJ2fW.png" alt="enter image description here"></p>
  
  <p><img src="https://i.stack.imgur.com/Wfrd4.png" alt="enter image description here"></p>
  
  <p>Here is my code :</p>
  
  <pre><code> @Override
  protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  
  
      int childWidthMeasureSpec = MeasureSpec.makeMeasureSpec(
              MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY);
      int childHeightMeasureSpec = MeasureSpec.makeMeasureSpec(
              MeasureSpec.getSize(heightMeasureSpec), MeasureSpec.EXACTLY);
  
  
      setMeasuredDimension(childWidthMeasureSpec,childHeightMeasureSpec);
  
  
  }
  
  
  @Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
  
      Drawable outer_ring = getResources().getDrawable(R.drawable.outer_ring);
  
      System.out.println("Height now is : "+(canvas.getHeight()));
  
      Rect r1 = new Rect();
      r1.top = (canvas.getHeight()-outer_ring.getIntrinsicHeight());
      r1.bottom = canvas.getHeight();
      r1.left = (canvas.getWidth()-outer_ring.getIntrinsicWidth())/2;
      r1.right = canvas.getWidth()/2 +outer_ring.getIntrinsicWidth()/2;
  
      outer_ring.setBounds(r1);
      outer_ring.draw(canvas);
  
      Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
      paint.setColor(Color.BLACK);
      paint.setStyle(Style.STROKE);
      paint.setStrokeWidth(10.0f);
  
      canvas.drawCircle(canvas.getWidth()/2, ((canvas.getHeight()-outer_ring.getIntrinsicHeight()/2)), 20, paint);
  }
  </code></pre>
  
  <p>what should be the solution that this view appears same on all resolution</p>
  
  <p>Here is my layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
  
  
      &lt;com.example.testing.CustomMenu
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/myView"
          /&gt;
  
      &lt;Button
          android:id="@+id/button1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:text="Button" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>