結構デフォルトで満足してしまっている部分もあるのですが、Toastのカスタマイズがカンタンに行えるようです。
Toast _tst = new Toast(getApplicationContext()); _tst.setDuration(Toast.LENGTH_SHORT); LayoutInflater _inflater = getLayoutInflater(); View _v = _inflater.inflate(R.layout.toastlayout, null); _tst.setView(_v); _tst.show();
上記みたいな感じでinflateを用いれば、好きなレイアウトで作成ができるみたいです。
ここで大きいのは画像のデータも問題なく扱える事で、上記はサンプルなので、下記のようなxmlにしています
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="match_parent" android:padding="10dip" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/cat" android:adjustViewBounds="true" android:gravity="center"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="10dip" android:padding="5dip" android:background="#ffffff" android:text="@string/hello" android:textColor="#999999" android:gravity="center"/> </LinearLayout> </FrameLayout>
画像のパスなども設定しているのですが、もちろん画像のパスはかかなくて、スクリプトで設定をする事もできます。
割とこのトーストを遊んだアプリが少ないのですが、可能性のある機能だと思っています。
是非お試しくださいませ。