1
나는 약간의 달력 이미지를 찍고 그 위에 날짜와 달을 쓰고 싶다. 이 목록보기에서 여러 번 표시됩니다, 그래서 그것을 할 수있는 최적의 방법을 찾고 있습니다.이미지에 텍스트를 쓰는 가장 좋은 방법은 무엇입니까?
ImageView image = (ImageView) findViewById(R.id.imageView2);
try {
// Load the png image into a bitmap
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.calendar_empty);
// Have to copy the bitmap so it is mutable
mBitmap = mBitmap.copy(Bitmap.Config.ARGB_8888, true);
// Create a canvas from the bitmap to draw on
Canvas canvas = new Canvas(mBitmap);
Paint paint = new Paint();
paint.setColor(Color.BLACK);
paint.setTextSize(12);
paint.setAntiAlias(true);
canvas.drawText("Sept", 11, 26, paint);
paint.setTextSize(18);
canvas.drawText("29", 14, 42, paint);
// Display the results on the screen
image.setImageDrawable(new BitmapDrawable(this.getResources(), mBitmap));
} catch (Exception e) {
e.printStackTrace();
}
오버레이 방법을 사용하면 디스플레이의 밀도를 얻고 그에 따라 모든 계산을 확장해야합니까? 위의 방법으로 안드로이드 시스템은 이미지의 크기를 자동으로 조정합니다. – pcm2a
TextView 위젯의 텍스트의 실제 크기가 화면 밀도가 다른 여러 장치에서 동일하게 유지됩니까? 그렇다면 TextView가이를 처리합니다. dip에서 textSize를 정의 할 수 있습니다. –
이미지 뷰의 텍스트 위치와 그 위치. 예를 들어 100px x 100px 이미지는 화면 밀도에 따라 70px 또는 150px가 될 수 있습니다. 내 텍스트 X, Y 픽셀을 배치하고 모든 해상도에서 완벽하게 정렬해야합니다. – pcm2a