views:

160

answers:

1

LEts say you have a normal textview, with "Stackoverflow" written in it, I would like to know if it it possible to rotate the textview about -90°, to have the S at the bottom and the W at the top of the screen? of course, i could write my text in an image, rotate it and use it that way, but im interested in text right now. thank you

+1  A: 

You can set your textview as you would normally do

for example:

 <TextView android:id="@+id/txtview"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content" />

and write a function in your activity to

  • reverse the characters in your text
  • insert \n after every characters

and then set the text to the TextView.

If you dont want to insert the \n, you will have to set the size of android:layout_width and play with font size not to have 2 characters fitting on the same line and no truncation

Edit If I have understood you correctly, you can get what you want by using animation.

For example

Under res/animation/myanim.xml:

<rotate  xmlns:android="http://schemas.android.com/apk/res/android"
           android:fromDegrees="0" 
           android:toDegrees="-90"
           android:pivotX="50%"
           android:duration="0" />

You will have to play with this file to define where you want your text view to be placed.

In your activity:

  TextView t = (TextView)findViewById(R.id.txtview);
  String txt = "Stackoverflow";         
  t.setText(txt);

  RotateAnimation ranim = (RotateAnimation)AnimationUtils.loadAnimation(this, R.anim.myanim);
  ranim.setFillAfter(true); //For the textview to remain at the same place after the rotation
  t.setAnimation(ranim);
ccheneson
Yeah I though about that but that is not what I explained and asked for actually, i don't want each character one on top of the other, but all of them with a -90° rotation... is this possible?
Sephy
aha ok - I think I know what you mean now - I have no idea how to do that but I ll think about it
ccheneson
Yeah that's great idea.
Sephy