I have gone through some solutions but none solve my issue.
I have created a custom DialogFragment
. and root element of dialog is cardView
. I set cardCornerRadius
of cardView
.
Then i try to set Transparent Dialog because background color is also showing with it.
then i try to set the dialog theme like
<style name="PauseDialog" parent="@style/Theme.AppCompat.Light.Dialog">
<!-- TTheme.AppCompat.Translucent-->
<item name="android:windowAnimationStyle">@style/PauseDialogAnimation</item>
<!--<item name="android:windowBackground">@android:color/transparent</item>-->
<item name="android:windowBackground">@color/transparent</item>
<item name="android:colorBackgroundCacheHint">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowTitleStyle">@null</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
<item name="android:backgroundDimEnabled">false</item>
<item name="android:background">@android:color/transparent</item>
</style>
The background still remains there. And then I also tried
dialog.getWindow().setBackgroundDrawable(
new ColorDrawable(Color.TRANSPARENT));
but still dialog have background associated with it.
Is there any work around. How could i get rid of it.
I have created a DialogFragment and in onCreateDialog
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(),
R.style.PauseDialog);
setStyle(DialogFragment.STYLE_NO_FRAME, R.style.PauseDialog);
You can simply use MaterialAlertDialogBuilder to create custom dialog with rounded corners. then create a Alert Dialog object in Java class like this : AlertDialog alertDialog = new MaterialAlertDialogBuilder(this,R. style.
If you want a custom layout in a dialog, create a layout and add it to an AlertDialog by calling setView() on your AlertDialog. Builder object.
How do I make ALert dialog background transparent? setBackgroundColor(Color. TRANSPARENT); wv. setPadding(5, 25, 5, 0); ImageView imgcartl=(ImageView)layout.
If you want rounded corner you can try apply custom shape using xml to your custom dialog backgroud. Following code will help you out.
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#FFFFFF" />
<corners
android:radius="10dp"/>
</shape>
You can remove cardview as top element because dialog has its on shadow and depth. Add this line before you set contentview to dialog
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With