在Android中制造彩色吐司 [英] Making a Color Toast in Android

查看:264
本文介绍了在Android中制造彩色吐司的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有时看到显示出来的时候我带wifi网络连接我的三星手机一个蓝色敬酒。任何人都可以帮助定制敬酒的颜色。

I have seen sometimes a Blue toast showing up when i connect my Samsung phone with wifi network. Can anyone help for customising the colour of the toast.

例如:

推荐答案

像这样的:

LayoutInflater inflater = youractivity.this.getLayoutInflater();
            View layout = inflater.inflate(R.layout.custom_toast,
                    null);
            TextView text = (TextView) layout.findViewById(R.id.tvtoast);
            text.setText("No Internet Connection");
            text.setTextColor(Color.BLACK);
            Toast toast = new Toast(getActivity());
            toast.setView(layout);
            toast.setDuration(100);
            toast.show();

请自己的布局 custom_toast.xml 并设置颜色的TextView 文本根据自己的需要

Make your own layout custom_toast.xml and set Color to TextView Text as per your need

输出:

这篇关于在Android中制造彩色吐司的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆