アラートダイアログの明るい背景に暗い色でテキストを表示したい。しかし、私はこれを行う方法を理解することはできません。私を助けてください。
ありがとう。
アラートダイアログの明るい背景に暗い色でテキストを表示したい。しかし、私はこれを行う方法を理解することはできません。私を助けてください。
ありがとう。
アクティビティの場合と同じように、XML ビューで独自のレイアウトを作成できます。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_root"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dp"
>
<ImageView android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_marginRight="10dp"
/>
<TextView android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:textColor="#FFF"
/>
</LinearLayout>
setContentView(View)
次に、ダイアログを呼び出して、ダイアログでこのビューを使用できます。
Context mContext = getApplicationContext();
Dialog dialog = new Dialog(mContext);
dialog.setContentView(R.layout.custom_dialog);
dialog.setTitle("Custom Dialog");
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.android);
例が示すように、コンテンツ ビューを宣言した後、いくつかの値を設定する必要があります。
http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialogから提供される例