I created a new custom dialog with an oval background. However, there is a margin on the dialog which I do not know how to remove. I've tried to apply custom themes to the dialog, but so far I have not found a way to remove this margin.
What made the difference for styling was this custom style xml:
<style name="BokiDialogTheme" parent="Theme.AppCompat.Dialog">
<item name="android:windowIsFloating">false</item>
<item name="android:windowBackground">#android:color/transparent</item>
</style>
Related
I have a Dialog that I display in my application, but I want to be able to change the semi-transparent black background to be 100% transparent. Like below, the part that grays out the activity behind the dialog, I'd like that to be transparent so that I can see the underlying activity as it, instead of being darkened. Thanks for your help!
I was able to achieve my desired result by creating the Dialog and passing a style to its constructor like so...
Dialog ad = new Dialog(context, R.style.SpinnerDialogDropdown);
<style name="SpinnerDialogDropdown">
<item name="android:windowFrame">#null</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
**<item name="android:backgroundDimEnabled">false</item>**
</style>
I have created my own custom dialog and it works fine but I want to change dimmed background to a custom pattern (for example an image file or a xml shape). How can I achieve that?
Note that I do not want to change intensity of dimming but I just want, this dimming be replaced with a pattern
I found a workaround for this problem, I derived this from #vipul mittal answer,
I should set dialog theme as following:
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
With this theme my dialog will be:
full screen because windowIsFloating is set to false
surrounding area is fully transparent because windowBackground is set to #android:color/transparent
Now I should wrap my dialog xml layout contents with a wrapper that plays surrounding area role, in this case I have picked FrameLayout for this:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/dialog_back"> <!-- this is surrounding area drawable -->
<!-- dialog contents goes here -->
</FrameLayout>
Here is a screenshot of my final dialog:
Change dialog theme to:
<style name="CustomDialogTheme" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#android:color/white</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoTitle">true</item>
</style>
In custom dialog when you call super call this:
public CustomDialog(Context context) {
super(context, R.style.CustomDialogTheme);
}
I'm trying to do a Transparent Activity, with a custom layout containing A DatePicker and a Time Picker side by side,
The activity should be transparent and dimmed, while the DatePicker and TimePicker should be with Holo.Light style.
the only way i got it to work was theming the activity with Holo.Dialog which prevents me from displaying the container in fill_parent.
The trouble is, that i can't seem to find the right style, event tried a custom style with Holo.Light as the parent style.
any suggestions ?
thanks
I ended up solving the issue by expanding from Holo.Light like so:
<style name="Theme.Translucent.Pickers" parent="android:Theme.Holo.Light">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowNoTitle">true</item>
<item name="android:backgroundDimEnabled">true</item>
Im using Theme.Holo.Light.DarkActionBar but I dont really like the Light Dialogs/AlertDialogs.
I want to change every Dialog to the dark Holo Dialog.
<style name="CustomDialogTheme" parent="#android:style/Theme.Holo.Dialog">
<item name="#android:background">#9933CC</item>
<item name="#android:textColor">#02FA07</item>
</style>
<style name="Holo.Light.DarkActionBar" parent="#android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:dialogTheme">#style/CustomDialogTheme</item>
<item name="android:alertDialogStyle">#style/CustomDialogTheme</item>
</style>
Thats what I tried but it has no effect on any Dialogs.
Ok nvm Im stupid its android:alertDialogTheme instead of android:alertDialogStyle. But this messes up the Preference Dialogs, so I just keep using the Light Dialogs.
In AndroidManifest.xml under the application tag, add this line :
android:theme="Holo.Light.DarkActionBar"
The issue is that the styles you're changing android:background and android:textColor are not dialog attributes.
You can see a full list here under Theme.Holo.Dialog on line 1617.
The ones you have to change are probably android:windowBackground and textAppearance
I'm creating an AlertDialog. I'm using setView() to set a custom view. This enables the 'dark' theme on the dialog (grey background, and need white text).
Is there a way to set the dialog to use the 'light' theme? It looks nicer (white background, dark text).
Thanks
Steps I took:
Create a class extending Dialog.
In the onCreate, call
setContentView(x, y) with x being
your R.layout and y being
R.style.popupStyle (see below).
In your res/values/style.xml, you
need to override the default
DialogWindow style. I tried just
making a style that has this one as
its parent, but that still didn't
clear all defaults. So I checked the
Android git tree and got the default
style, and just copy-pasted it. This
is the one
:
<style name="Theme.Dialog">
<item name="android:windowFrame">#null</item>
<item name="android:windowTitleStyle">#android:style/DialogWindowTitle</item>
<item name="android:windowBackground">#android:drawable/panel_background</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowAnimationStyle">#android:style/Animation.Dialog</item>
<item name="android:windowSoftInputMode">stateUnspecified|adjustPan</item>
</style>
You'll get a few errors, just solve them by copying more stuff from the official Android styles.xml and themes.xml files.
for reference: styles.xml and themes.xml.