When I try to rotate a TextView (width 300, height 240) by extending
the class TextView and overriding the onDraw method by the following
code:

@Override
protected void onDraw(Canvas canvas) {
     canvas.save();
     canvas.rotate(90);
     super.onDraw(canvas);
     canvas.restore();
}

Then the text in the text view is not visible. If I rotate it 45
degrees then the text is in the view again.

It seem to me that it rotates on the top left corner so the text is
rotated out of the view and is now just left of the view. So I used
the rotate method with the px and py parameters like:

    canvas.rotate(90, 150, 150);

Now the text is on the top right corner of my view, just like I want
it. But, the width of the vertical text is 300 and the height 240, so
again a part of the text is out of the view witch is 300x240.

The view is part of a relative layout, see activity code below:

@Override
public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);

     final RelativeLayout rl = new RelativeLayout(this);

     RelativeLayout.LayoutParams lprms = new
RelativeLayout.LayoutParams(
         LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT);
     lprms.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
     lprms.rightMargin =10;
     lprms.leftMargin = 10;
     lprms.topMargin = 10;

     final CustomTextView tx = new CustomTextView(this,90,150,150);
     tx.setLayoutParams(lprms);
     tx.setText("Test Text Test Text Test Text Test Text Test Text
Test Text");
     tx.setWidth(300);
     tx.setHeight(240);
     tx.setBackgroundColor(Color.RED);
     tx.setSingleLine(false);
     tx.setTextSize(12);

     rl.addView(tx ,0);

     setContentView(rl);
}

I hope there is a solution or work arround for this, cause I realy
need vertical text objects.

Thanks in advance!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to