Android中自定义特定颜色的Toast
2015-02-01 19:57
302 查看
/** * 展示一个特定颜色的Toast * * @param message */ protected void toast(String message) { View toastRoot = LayoutInflater.from(context).inflate(R.layout.toast, null); Toast toast = new Toast(context); toast.setView(toastRoot); TextView tv = (TextView) toastRoot.findViewById(R.id.toast_notice); tv.setText(message); toast.show(); }Toast的布局文件如下
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/toast_border"> <TextView android:id="@+id/toast_notice" android:layout_width="wrap_content" android:layout_height="@dimen/toast_height" android:layout_gravity="center_vertical" android:gravity="center_vertical" android:textColor="@color/app_toast_text"> </TextView> </LinearLayout>
相关文章推荐
- Android 自定义toast总结:纯文本,带图像,带标题栏及自定义背景文字颜色
- Android Toast自定义 (一个textview多种颜色,或试用html多种颜色)
- Android自定义边框背景颜色的Toast
- android 小常识(包含一些界面开发的推荐颜色和自定义按钮~)
- android中自定义toast
- Android中的Toast的标准格式和自定义格式
- android 小常识(包含一些界面开发的推荐颜色和自定义按钮~)
- android界面设计——自定义边框背景的Toast
- Android软件开发之 自定义别样Toast
- Android中ProgressBar自定义进度条的高度、颜色、圆角
- Android中Toast显示时间的自定义
- Android中自定义SeekBar的背景颜色,进度条颜色,以及滑块的图片
- [Android]可自定义显示时长的Toast
- Android进阶篇-Toast自定义显示时间
- Android深入浅出系列之实例应用—弹出消息Toast对象的使用自定义方式(二)
- Android Toast用法详解(各种自定义Toast)
- Android中自定义Toast
- Android---功能模块一之颜色选择器自定义Preference 对话框
- Android中自定义SeekBar的背景颜色,进度条颜色,以及滑块的图片
- Android 自定义Toast