吐司背景改变,以配合活动的主题吐司、背景、主题

由网友(Sweetゞ呆呆猪。)分享简介:我创建了一个自定义的主题我的活动,他们都使用。在这个主题,我设置的android:背景,而这种情况造成任何对话或吐司消息看起来很奇怪。I have created a custom theme for my activities that they all use. In the theme, I set andro...

我创建了一个自定义的主题我的活动,他们都使用。在这个主题,我设置的android:背景,而这种情况造成任何对话或吐司消息看起来很奇怪。

I have created a custom theme for my activities that they all use. In the theme, I set android:background, and this happens to cause any dialog or toast message to look very strange.

我如何prevent烤面包和吸收主题的属性中的其他对话?

How do I prevent toast and the other dialogs from absorbing the theme's properties?

推荐答案

您可以很容易地通过以下code创建自定义敬酒:

You can easily create custom toast by the following code:

Toast toast = Toast.makeText(context, resTxtId, Toast.LENGTH_LONG);
View view = toast.getView();
view.setBackgroundResource(R.drawable.custom_bkg);
TextView text = (TextView) view.findViewById(android.R.id.message);
/*here you can do anything with text*/
toast.show();

或者你可以实例化一个完全自定义的敬酒:

Or you can instantiate a completely custom toast:

Toast toast = new Toast(context);
toast.setDuration(Toast.LENGTH_LONG);

LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
View view = inflater.inflate(R.layout.custom_layout, null);
toast.setView(view);
toast.show();

对话框定制是一个更复杂的程序。但有类似的解决办法。

Dialog customizing is a more complex routine. But there is similar workaround.

阅读全文

相关推荐

最新文章