title: Android canvas drawLine not full width
body: <p>I need to draw a line in a fragment. I have no problem to do that but I don't know why the line has a left and right margin (top and bottom is fine).</p>
  
  <p>Here's my code:</p>
  
  <pre><code>@Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          context = container.getContext();
          utili = new Utilities(context);
          View rootView = inflater.inflate(R.layout.statsdepth_layout, container, false);
          gfxView = (ImageView) rootView.findViewById(R.id.gfxview);
          int width = context.getResources().getDisplayMetrics().widthPixels;
          int height = context.getResources().getDisplayMetrics().heightPixels;
          Log.i("LOGTAG", "W: " + width + " H: " + height);
          Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
          Canvas canvas = new Canvas(bitmap);
  
          Paint paint = new Paint();
          paint.setColor(Color.rgb(255, 153, 51));
          paint.setStrokeWidth(10);
          int startx = 0;
          int starty = 90;
          int endx = width;
          int endy = 90;
          canvas.drawLine(startx, starty, endx, endy, paint);
          gfxView.setImageBitmap(bitmap);
  
          return rootView;
      }
  </code></pre>
  
  <p>Here's the xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
      &lt;ImageView
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/gfxview"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>**** UPDATE ***</p>
  
  <p>Changing layout as below, it fixed:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="match_parent"
      android:layout_height="match_parent"&gt;
  
  &lt;ImageView
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:id="@+id/gfxview"
      android:scaleType="matrix"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And here's the result (I expect the line is full width large)</p>
  
  <p><a href="https://i.stack.imgur.com/8ragu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8ragu.png" alt="enter image description here"></a></p>