如何自定义吐司Android中?吐司、自定义、Android

2023-09-06 03:34:28 作者:Unique﹌独一无二

时有可能使自定义吐司的Andr​​oid系统。一样,如果我们可以在上面放置图像图标和地点按钮。

Is it possible to make Customize Toast in Android. like if can we place in it image icon and place button.

推荐答案

您也可以使用常规makeText()和处理的 getView()设置,看到未来下一个图像。

You can also use the regular makeText() and handle the getView() to set an image next to see the next.

Toast toast = Toast.makeText(context, text, Toast.LENGTH_SHORT);
TextView tv = (TextView) toast.getView().findViewById(android.R.id.message);
if (null!=tv) {
    tv.setCompoundDrawablesWithIntrinsicBounds(icon, 0, 0, 0);
    tv.setCompoundDrawablePadding(context.getResources().getDimensionPixelSize(R.dimen.padding_toast));