0
我試圖創建一個具有以下代碼旋轉一個TextView和重新測量在Android的
public class VerticalTextView extends TextView{
public VerticalTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
public VerticalTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
}
public VerticalTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@Override
protected void onDraw(Canvas canvas) {
Log.i("VerticalTextView", "onDraw Called");
canvas.save();
canvas.rotate(-90, getWidth()/2, getHeight()/2);
super.onDraw(canvas);
canvas.restore();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
// TODO Auto-generated method stub
super.onMeasure(heightMeasureSpec, widthMeasureSpec);
super.setMeasuredDimension(getMeasuredHeight(), getMeasuredWidth());
}
}
但是我發現,它沒有重新定義新高度全寬垂直的TextView。因此文本真的被截斷。
任何想法? 米
非常感謝,不知道我錯過了它! – mAndroid 2011-12-18 13:07:21