글 수 74
2014.04.04 17:08:08 (*.134.169.166)
19353
세로 텍스트 뷰를 만들 수 있는 클래스를 만들어 보앗습니다.
import android.content.Context; import android.graphics.Canvas; import android.text.TextPaint; import android.util.AttributeSet; import android.view.Gravity; import android.widget.TextView; public class VerticalTextView extends TextView { public VerticalTextView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(heightMeasureSpec, widthMeasureSpec); setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth()); } @Override protected void onDraw(Canvas canvas) { TextPaint textPaint = getPaint(); textPaint.setColor(getCurrentTextColor()); textPaint.drawableState = getDrawableState(); canvas.save(); canvas.translate(0, getHeight()); canvas.rotate(-90); canvas.translate(getCompoundPaddingLeft(), getExtendedPaddingTop()); getLayout().draw(canvas); canvas.restore(); } }
사용해 보면 대략 다음과 같이 나옵니다.