package com.example.textpaint;
 
import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.TextView;
 
public class MainActivity extends Activity {
    private TextView mPaintText;
    private Paint textPaint, strokePaint, textPaint2, strokePaint2;
  
@Override
 
public void onCreate(Bundle savedInstanceState) {
 
super.onCreate(savedInstanceState);
 
// setContentView(R.layout.activity_main);
 
initPaint();
 
setContentView(new MyView(getApplicationContext()));
}
 
  
 
private void initPaint() {
 
    int textSize = 100;
    textPaint = new Paint();
    textPaint.setAntiAlias(true);
    textPaint.setColor(Color.WHITE);
    textPaint.setTextSize(textSize);
 
    strokePaint = new Paint();
    strokePaint.setAntiAlias(true);
    strokePaint.setTextSize(textSize);
    strokePaint.setColor(Color.BLACK);
    strokePaint.setStyle(Paint.Style.STROKE);
    strokePaint.setStrokeWidth(4);
 
    int textSize2 = 50;
 
    textPaint2 = new Paint();
    textPaint2.setAntiAlias(true);
    textPaint2.setColor(Color.BLUE);
    textPaint2.setTextSize(textSize2);
      
 
    strokePaint2 = new Paint();
    strokePaint2.setAntiAlias(true);
    strokePaint2.setTextSize(textSize2);
    strokePaint2.setColor(Color.BLACK);
    strokePaint2.setStyle(Paint.Style.STROKE);
    strokePaint2.setStrokeWidth(4);
    }
 
 class MyView extends View{
 
        public MyView(Context context) {
            super(context);
        }
         
        @Override
        protected void onDraw(Canvas canvas) {
            super.onDraw(canvas);         
 
            String text = "48.2";
 
     canvas.drawText(text, 100, 100, strokePaint);
     canvas.drawText(text, 100, 100, textPaint);
 
     String text2 = "%";
     canvas.drawText(text2, 320, 100, strokePaint2);
     canvas.drawText(text2, 320, 100, textPaint2);
//     canvas.drawText(text, x, y, strokePaint);
//     canvas.drawText(text, x, y, textPaint);
        }
   }
 
  
 
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}


Posted by MR 손
,