Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android -- Is there a way to rotate a toast 90 degrees?

Can't think of any more info to provide. Is there a way?

like image 566
farm ostrich Avatar asked Jun 04 '11 03:06

farm ostrich


1 Answers

As hackbod said, you would have to have a custom view to display the toast.

I found a few classes for you that rotates the label for you: VerticalLabelView and CustomTextView

I chose to use the latter, and had this code working in my own app:

// Creating a new toast object
Toast myToast = new Toast(MyActivity.this);
// Creating our custom text view, and setting text/rotation
CustomTextView text = new CustomTextView(MyActivity.this);
text.SetText("Hello World!");
text.SetRotation(-90, 120, 90);
myToast.setView(text);
// Setting duration and displaying the toast
myToast.setDuration(Toast.LENGTH_SHORT);
myToast.show();
like image 147
Frxstrem Avatar answered Nov 05 '22 10:11

Frxstrem