Я работаю с Android DialogИзменение цвета диалогового андроида
Я хочу, чтобы удалить два черного цвета в этом диалоге. Но, похоже, я не могу этого сделать.
Это мой макет
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/color_loading_background_white">
<ImageView
android:src="@drawable/ic_logo"
android:layout_width="230dp"
android:layout_height="64dp"
android:layout_marginTop="10dp"
android:scaleType="centerCrop"
android:contentDescription="@string/app_name"
android:layout_gravity="center_horizontal"/>
<EditText
android:id="@+id/username"
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginBottom="4dp"
android:hint="Enter username" />
</LinearLayout>
И это мой код при создании диалога.
public static void showDialog(Activity activity, int layout, final IOnOkClicked cb, final IOnCancelClicked cb2) {
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
// Get the layout inflater
LayoutInflater inflater = activity.getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(layout, null))
// Add action buttons
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
if (cb != null) {
cb.onClick();
}
}
})
.setCancelable(false);
if (cb2 != null) {
builder.setNegativeButton(activity.getString(R.string.cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
cb2.onClick();
}
});
}
builder.create().show();
}
Пожалуйста, дайте мне совет для этого. Спасибо!
Попробуйте установить фон прозрачным и дизайн вашего диалога, как, как вы хотите yourcustomdialog.getWindow() setBackgroundDrawable ( \t \t \t \t нового ColorDrawable (android.graphics.Color.TRANSPARENT)). – Madhu
Я уже установил его, но он не меняет цвет –
О, в этом случае вы пытались установить диалоговую тему как андроид.R.style.Theme_Light – Madhu