gpt4 book ai didi

android - 创建来自屏幕顶部的 Toast

转载 作者:行者123 更新时间:2023-11-29 15:08:28 26 4
gpt4 key购买 nike

我想知道我们如何在 Android 中创建自定义 toast 并像这样显示在屏幕顶部?

enter image description here

我来自 iOS 背景,现在我必须创建这样的自定义控件。

有什么建议吗?

谢谢

最佳答案

检查此链接:https://github.com/gfranks/GFMinimalNotifications ,这就是你想要的,我认为它对我来说工作正常。

输出:

enter image description here

或者您可以像这样准备自定义 toast :

View layout = getLayoutInflater().inflate(R.layout.customtoast,
(ViewGroup) findViewById(R.id.custom_toast_layout));
Toast toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.TOP, 0, 0);
toast.setView(layout);
toast.show();

关于android - 创建来自屏幕顶部的 Toast,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34448276/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com