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

匿名 (未验证) 提交于 2019-12-03 01:48:02

问题:

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

回答1:

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


回答2:

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



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!