【问题标题】:How to make Toast show at the TOP?如何在TOP制作吐司秀?
【发布时间】:2021-06-08 12:53:39
【问题描述】:

我的 Toast 无法显示在 TOP 上。

以下代码仍在底部打印吐司。我做错了吗?

falseButton.setOnClickListener { view: View ->
            val toast = Toast.makeText(
                this,
                "Incorrect",
                Toast.LENGTH_SHORT)
                toast.setGravity(Gravity.TOP, 0, 0)
                toast.show()

        }

感谢您的帮助。

【问题讨论】:

标签: android toast gravity


【解决方案1】:
Toast mytoast= Toast.makeText(getApplicationContext(), "Toast Message", 1);  
mytoast.setGravity(Gravity.TOP);                  
mytoast.show();

这应该适用于当前活动。

【讨论】:

    猜你喜欢
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-09
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多