9

我想通过编辑更改我的应用程序中的所有 toasts themes.xml

<item name="buttonStyle">@style/MyButton</item>用来更改我的按钮,是否有与 Toast 类似的东西,或者我是否必须创建和使用MyToast扩展内置 Toast 的类?

4

2 回答 2

6

您可以使用以下方法更改 Toast 的背景:

<style name="myTheme" parent="@android:styles/Theme.Holo">
  <item name="android:toastFrameBackground">@android:drawable/my_toast</item>
</style>
于 2013-04-06T19:10:53.950 回答
-3

试试这个:

 Toast toast=new Toast(this);
     LayoutInflater inflater=this.getLayoutInflater();
     View toastView=inflater.inflate(R.layout.toast_layout, (ViewGroup)findViewById(R.id.toastView));
     TextView txtDate=(TextView)toastView.findViewById(R.id.txtDate);
     txtDate.setText("toast appeared at "+Calendar.getInstance().getTime().toLocaleString());
     toast.setGravity(Gravity.CENTER, 0, 0);
     toast.setView(toastView);
     toast.show();
于 2013-04-05T11:50:00.143 回答