Reputation: 571
I want to use a custom view for my dialog but the problem is when I use the custom layout and I don't get a beautiful layout . this is the result of my code :
as you can see, it fits the screen with , the corners are in bad shape . here is a dialog that not using a custom layout :
this is my code :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="20dp"
android:paddingLeft="7dp"
android:background="@android:color/white"
android:paddingRight="7dp"
android:paddingTop="20dp">
if I don't use background color, the dialog will have no background color and it'll be transparent .
for the dialog that is not using custom dialog , I use these styles :
<style name="MaterialDialogSheet" parent="@android:style/Theme.Dialog">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowAnimationStyle">@style/MaterialDialogSheetAnimation</item>
</style>
<style name="MaterialDialogSheetAnimation">
<item name="android:windowEnterAnimation">@anim/popup_show</item>
<item name="android:windowExitAnimation">@anim/popup_hide</item>
</style>
How can I make my custom dialog background like the dialog that is not using a custom layout ?
Upvotes: 0
Views: 2083
Reputation: 17986
A little late on this but here is how to do it in your style:
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
...
<item name="alertDialogTheme">@style/myAlertDialogStyle</item>
</style>
<style name="myAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">@color/Blue</item>
</style>
colorAccent
will color the inputs of the dialogs.
Upvotes: 2