开发者

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

开发者 https://www.devze.com 2023-03-10 13:59 出处:网络
Can\'t think of any more info开发者_如何学Go to provide. Is there a way?As hackbodsaid, you would have to have a custom view to display the toast.

Can't think of any more info开发者_如何学Go to provide. Is there a way?


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();


Not an easy way. You can supply your own view to display the toast, so you can make a view that rotates its content.

0

精彩评论

暂无评论...
验证码 换一张
取 消