我有一个自定义吐司通知,其中有一个图像和文本。定制的吐司运行良好,但是我想知道如何让我的定制吐司继承默认的吐司外观和感觉?我希望它看起来像一个漂亮的圆角和边框默认的。
这就是我定制的吐司的样子。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toast_layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
android:background="#DAAA">
<ImageView android:id="@+id/chatIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:src="@drawable/ic_chat"/>
<TextView android:id="@+id/text"
android:text="@string/unread_message_toast"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>
发布于 2011-12-31 14:21:42
我在我的一个应用程序中使用了这个。改变一些周围的东西,它也应该对你有效。
Toast ImageToast = new Toast(getBaseContext());
LinearLayout toastLayout = new LinearLayout(
getBaseContext());
toastLayout.setOrientation(LinearLayout.HORIZONTAL);
ImageView image = new ImageView(getBaseContext());
image.setImageResource(R.drawable.easter_egg);
toastLayout.addView(image);
ImageToast.setView(toastLayout);
ImageToast.setDuration(Toast.LENGTH_SHORT);
ImageToast.show();
发布于 2015-11-08 07:10:25
要获得带有漂亮圆角的默认背景(在棒棒糖上),请使用:
android:background="@android:drawable/toast_frame"
或
android:background="?android:attr/toastFrameBackground"
它会根据安卓的版本给出吐司的背景,如果你想要最新的版本,我建议在..sdk\platforms\android-latest version\data\res\drawable-density下查找toast_frame.9.png文件
文本样式:
android:textAppearance="@android:style/TextAppearance.Toast"
android:textColor="@android:color/bright_foreground_dark"
android:shadowColor="#BB000000"
android:shadowRadius="2.75"
发布于 2011-12-31 14:18:45
尝尝这个
<style name="Themename" parent="android:Theme.dialog">
来自developer.android.com/guide/topics/ui/themes.html
https://stackoverflow.com/questions/8686398
复制相似问题