티스토리 뷰
package net.guyaga;
import android.app.Activity;
import android.os.Bundle;
public class StringEx extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(new StringView(this));
}
}
|
StringView.java
package net.guyaga;
import android.content.Context; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; import android.view.View;
public class StringView extends View { public StringView(Context context){ super(context); setBackgroundColor(Color.BLACK); }
@Override protected void onDraw(Canvas canvas){ Paint paint = new Paint(); paint.setAntiAlias(true); paint.setTextSize(12); paint.setColor(Color.argb(255, 255, 255, 255));
//화면크기 canvas.drawText("화면크기 : "+getWidth() + "X"+getHeight(), 0, 30, paint); //문자폭 canvas.drawText("문자폭 : "+(int)paint.measureText("A"), 0, 30*2, paint); //어센트 canvas.drawText("어센트 : "+(int)paint.ascent(), 0, 30*3, paint); //디센트 canvas.drawText("디센트 : "+(int)paint.descent(), 0, 30*4, paint); //문자 크기 - 12 red paint.setTextSize(12); paint.setColor(Color.argb(255, 255, 0, 0)); canvas.drawText("12dot", 0, 30*5, paint); //문자 크기 - 16 blue paint.setTextSize(16); paint.setColor(Color.argb(255, 0, 0, 255)); canvas.drawText("16dot", 0, 30*6, paint); //문자크기 - 24 green paint.setTextSize(24); paint.setColor(Color.argb(255, 0, 255, 0)); canvas.drawText("24dot", 0, 30*7, paint); } } |
실행결과 화면
'OS > Android' 카테고리의 다른 글
안드로이드 설치중 오류사항... (0) | 2011.08.01 |
---|---|
Desire SDcard 인식이 안될경우 (0) | 2011.06.22 |
Desire bluetooth가 작동하지 않을시 (0) | 2011.06.22 |
[롬] [11.07.2010] vErnarDo-V4_kernel experiment Version FULL ROM 업로드완료 (0) | 2010.11.08 |
[롬] [11.02.2010] R5.8 vErnarDo_BFQa FULL 업로드완료 (0) | 2010.11.08 |