开发者

How to Change the alignment of Toast by Programmatically? [duplicate]

This question already has answers here: Closed 11 years ago.
开发者_开发技巧

Possible Duplicate:

how to change position of Toast in android?

How to change the Alignment for Toast? Basically, toast it'll displays information bottom of the device. How can we change that? Anyone help me to find out this? Thanks in Advance.


It would be a nice idea to create a Custom Toast like this,

        TextView textview = new TextView(context);
        textview.setText(text);
        textview.setBackgroundColor(Color.GRAY);
        textview.setTextColor(Color.BLUE);
        textview.setPadding(10,10,10,10);
        Toast toast = new Toast(context);
        toast.setView(textview);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM, 0, 0);
        toast.show();

By this you can place the Toast to anywhere you want using Gravity

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜