在android画布上画一条线

时间:2016-07-25 04:20:37

标签: android canvas

我想在android上的地图上画一条线(比如x轴)。我写下面的代码,但除了地图我还看不到任何东西。我的代码有什么问题吗? THX

protected void onCreate(Bundle savedInstanceState) {

       super.onCreate(savedInstanceState);

....
      Bitmap loadedBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.map);
      Bitmap drawableBitmap = loadedBitmap.copy(Bitmap.Config.ARGB_8888, true);

      Canvas canvas = new Canvas(drawableBitmap);
      Paint paint = new Paint();
      paint.setColor(Color.BLACK);
      canvas.drawLine(0, 0, canvas.getWidth(), 0, paint);//draw x axis
....
}

0 个答案:

没有答案