主にRPA、Androidアプリ開発について投稿しています。メモ書きです。
[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。
LinearLayout ll = (LinearLayout)findViewById(R.id.contentAll);カスタムトーストは以下。
GradientDrawable gd = new GradientDrawable();
gd.setColor(Color.parseColor("#FFFFFF"));
ll.setForeground(gd);
customToast();
private void customToast(){トーストのレイアウト
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.toast_layout, null);
// 画像を設定
ImageView toastImage = (ImageView) layout.findViewById(R.id.toastImage);
toastImage.setImageResource(R.drawable.toast);
// テキストを設定
TextView toastText = (TextView) layout.findViewById(R.id.toastText);
toastText.setText("今日も1日頑張ろう\nご安全に!");
Toast toast = new Toast(this);
toast.setView(layout);
// 中央に表示
toast.setGravity( Gravity.CENTER, 0, 0 );
toast.show();
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:background="@drawable/button_red"
>
<TextView android:id="@+id/toastText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#333"
android:text="本日もご安全に!\n今夜は飲みに行こうか。"
android:layout_gravity="center"
android:gravity="center_vertical"
android:textSize="48px"
/>
<ImageView
android:layout_gravity="center"
android:id="@+id/toastImage"
android:layout_width="200dip"
android:layout_height="200dip"
android:layout_marginRight="10dip"
android:src="@drawable/muroi"
/>
</LinearLayout>