CURRENT UPDATE: Still not solved!
Question: Is it possible that Dialog/AlertDialog/AlertDialogBuilder/MaterialAlaertDialogBuilder can works with combitation of rounded corners and DayNight theme at same time in Android?
I tired a lot, but I don't think that it is possible. Only one thing will work.
You can suggest me using material library.
Rounded corner with theme style is really possible in Dialog?
Code:
public void showFeedbackDialog(int code) {
exitCode = code;
dialog = new Dialog(context, R.style.dialogBoxStyle);
View dialogView = LayoutInflater.from(context).inflate(R.layout.row_feedback_dialog, null);
name = dialogView.findViewById(R.id.feedback_name);
email = dialogView.findViewById(R.id.feedback_email);
content = dialogView.findViewById(R.id.feedback_content);
TextView nameError = dialogView.findViewById(R.id.nameError);
emailError = dialogView.findViewById(R.id.emailError);
feedbackError = dialogView.findViewById(R.id.feedbackError);
progressBar = dialogView.findViewById(R.id.progress_bar);
skip = dialogView.findViewById(R.id.skip);
submit = dialogView.findViewById(R.id.button_positive);
cancel = dialogView.findViewById(R.id.button_negative);
dialog.setContentView(dialogView);
if (code == 101) {
skip.setVisibility(View.VISIBLE);
} else if (code == 102) {
skip.setVisibility(View.GONE);
}
dialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (checkValidation()) {
addFeedbackData();
}
}
});
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
skip.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (code == 101) {
FeedbackDialog.this.dialog.dismiss();
FixedCategorySingleton.getInstance().setNullObject();
activity.finishAffinity();
}
}
});
}
});
dialog.setCancelable(false);
dialog.show();
dialog.getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
}
row_feedback_dialog
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:focusableInTouchMode="true"
android:background="@drawable/dialog_positive_round"
app:cardCornerRadius="12dp"
android:orientation="vertical">
<include
layout="@layout/row_progress_bar"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<TextView
style="@style/dialog_hint_textview_style"
android:text="Please share your Feedback"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/hint_textview_style"
android:text="@string/name" />
<EditText
android:id="@+id/feedback_name"
style="@style/edit_text_style"
android:singleLine="true"
android:imeOptions="actionNext" />
</LinearLayout>
<include
android:id="@+id/nameError"
layout="@layout/row_error_textview" />
<!-- <EditText
android:id="@+id/feedback_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorIconLightGray"
android:hint="Name (Optional)"
android:inputType="textPersonName"
android:textColor="?attr/textcolor" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/hint_textview_style"
android:text="@string/email" />
<EditText
android:id="@+id/feedback_email"
style="@style/edit_text_style"
android:singleLine="true"
android:imeOptions="actionNext" />
</LinearLayout>
<include
android:id="@+id/emailError"
layout="@layout/row_error_textview" />
<!-- <EditText
android:id="@+id/feedback_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorIconLightGray"
android:hint="Email (Optional)"
android:inputType="textEmailAddress"
android:textColor="?attr/textcolor" />-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
style="@style/hint_textview_style"
android:text="What would you like to tell us?" />
<EditText
android:id="@+id/feedback_content"
style="@style/edit_text_style"
android:maxLines="4"
android:imeOptions="actionDone" />
</LinearLayout>
<!-- <EditText
android:id="@+id/feedback_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorIconLightGray"
android:gravity="top"
android:hint="What would you like to tell us?"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:lines="5"
android:textColor="?attr/textcolor" />-->
<include
android:id="@+id/feedbackError"
layout="@layout/row_error_textview" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/backgroundcolor">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:id="@+id/skip"
android:layout_width="70dp"
android:layout_height="40dp"
android:background="?attr/backgroundcolor"
android:text="@string/skip_caps"
android:textColor="?attr/textcolor"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="horizontal">
<Button
android:id="@+id/button_negative"
android:layout_width="70dp"
android:layout_height="40dp"
android:background="?attr/backgroundcolor"
android:text="@string/cancel"
android:textColor="?attr/textcolor" />
<Button
android:id="@+id/button_positive"
android:layout_width="70dp"
android:layout_height="40dp"
android:background="?attr/backgroundcolor"
android:text="@string/submit"
android:textColor="?attr/textcolor" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
style
<style name="dialogBoxStyle" parent="Theme.AppCompat.DayNight.Dialog.Alert">
<item name="android:background">?attr/backgroundcolor</item>
<item name="android:textColor">?attr/textcolor</item>
<item name="android:textColorAlertDialogListItem">?attr/textcolor</item>
<item name="android:textColorSecondary">?attr/textcolor</item>
<item name="android:textColorPrimary">?attr/textcolor</item>
<item name="colorAccent">?attr/textcolor</item>
<item name="android:typeface">normal</item>
<item name="textColorAlertDialogListItem">?attr/textcolor</item>
</style>
If I don't use theme then everything will work fine. corner are coming in rounded shape because of getWindow line. But, in my app I'm using theme also.
I request you to help me, I finally created this account because of I need solution.
UPDATE:
tried with material library, not giving any effect