title: draw arrows with Path in Android
body: <p>I read the article on <a href="http://www.curious-creature.org/2013/12/21/android-recipe-4-path-tracing/" rel="nofollow noreferrer">http://www.curious-creature.org/2013/12/21/android-recipe-4-path-tracing/</a></p>
  
  <p>Trying to draw arrows with Path which mentioned in the article, but with the following code, I got the half arrow, I already read articles about how to draw arrows on android. This question is more about "what's wrong with the following code." Thanks in advance.</p>
  
  <pre><code>package com.example.linepractice;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.LayoutInflater;
  import android.widget.LinearLayout;
  import android.widget.LinearLayout.LayoutParams;
  
  public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          PracticeLineView pl = new PracticeLineView(this);
          LayoutInflater mInflater = LayoutInflater.from(this);
          LinearLayout mainView = (LinearLayout) mInflater.inflate(R.layout.activity_main, null);
          LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
          params.setMargins(120, 120, 120, 120);
          pl.setLayoutParams(params);
          mainView.addView(pl);
          setContentView(mainView);
      }
  }
  
  
  package com.example.linepractice;
  
  import android.content.Context;
  import android.graphics.Canvas;
  import android.graphics.Paint;
  import android.graphics.Path;
  import android.view.View;
  
  public class PracticeLineView extends View {
      private Paint mPaint;
      public PracticeLineView(Context context) {
          super(context);
          mPaint = new Paint();
      }
  
      @Override
      protected void onDraw(Canvas canvas) {
          super.onDraw(canvas);
          canvas.translate(getPaddingLeft(), getPaddingTop() - getPaddingBottom());
          canvas.drawPath(makeArrow(140,140), mPaint);
      }
  
      private static Path makeArrow(float length, float height) {
          Path p = new Path();
          p.moveTo(-2.0f, -height / 2.0f);
          p.lineTo(length, 0.0f);
          p.lineTo(-2.0f, height / 2.0f);
          p.lineTo(-2.0f, -height / 2.0f);
          p.close();
          return p;
      }
  }
  </code></pre>
  
  <p>pic:
  <img src="https://i.stack.imgur.com/FMaxI.png" alt="code result"></p>