5

I am using Accengage (Ad4Push) and I want to customize its dialog. Accengage team said that it is possible to change dialog style with custom theme and I did that. I can change textSize, textColor, windowBackground but I still see the grey color on Dialog. Please see my photo Here. (I haven't got enough reputations to post an image)

I want to change all background dialog to white, but I don't know which attribute I can use for this purpose.

This is the attribute I am using.

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
        <item name="android:background">@color/background_holo_light</item>
        <item name="android:divider">@color/background_holo_light</item>
        <item name="android:dividerHorizontal">@null</item>
        <item name="android:dividerVertical">@null</item>
        <item name="android:textColor">@android:color/black</item>
        <item name="android:textColorPrimary">@android:color/black</item>
        <item name="android:buttonBarButtonStyle">@style/CustomDialogTheme.Button</item>
        <item name="android:padding">2dp</item>
        <item name="android:windowBackground">@android:color/transparent</item>
</style>

<style name="CustomDialogTheme.Button">
        <item name="android:background">@color/background_dark</item>
        <item name="android:textColor">@color/background_holo_light</item>
        <item name="android:layout_margin">8dp</item>
        <item name="android:layout_marginLeft">16dp</item>
        <item name="android:padding">8dp</item>
        <item name="android:gravity">center</item>
</style>

How I can make background of dialog become white. (I only can change the style with custom style, can not change programmatically, because this dialog come from third party library)

Pi Vinci
  • 381
  • 3
  • 10

3 Answers3

1

In onCreate add this line.

 dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

checkout this post. Dialog with transparent background in Android

Community
  • 1
  • 1
Muhammad Adil
  • 4,358
  • 3
  • 32
  • 36
1

Your question has already been answered here

Code from the link:

Add this to your styles.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="Theme.DoNotDim" parent="android:Theme">
        <item name="android:backgroundDimEnabled">false</item>
    </style>
</resources>

And then apply the theme to your activity:

<activity android:name=".SampleActivity" android:theme="@style/Theme.DoNotDim">
Dipakk Sharma
  • 976
  • 1
  • 8
  • 11
0

add this line in your theme (thanks to AAA)

<item name="android:windowBackground">@android:color/transparent</item>  

full style:

<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
    <item name="android:windowBackground">@android:color/transparent</item>  

    <item name="android:background">@color/background_holo_light</item>
    <item name="android:divider">@color/background_holo_light</item>
    <item name="android:dividerHorizontal">@null</item>
    <item name="android:dividerVertical">@null</item>
    <item name="android:textColor">@android:color/black</item>
    <item name="android:textColorPrimary">@android:color/black</item>
    <item name="android:buttonBarButtonStyle">@style/CustomDialogTheme.Button</item>
    <item name="android:padding">2dp</item>
</style>
Community
  • 1
  • 1
Nadeem Iqbal
  • 2,357
  • 1
  • 28
  • 43