Activity with DatePicker and TimePicker with Holo Light style - android

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>

Related

In Android, how do I remove the margins of a custom dialog?

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>

white background for date picker dialog shadow

I add datepicker to my application but my problem the shadow for the dialog have white background , use Android 21 for compile .
please help me to remove white background ...
I had the same problem,
First Solution I have done :
I end up giving this theme in the DatePickerDialog builder. What's important is the windowBackground set to transparent.
<style name="Theme.Yp.DatePicker" parent="#android:style/Widget.DeviceDefault.DatePicker">
<item name="android:textColor">#color/color_accent</item>
<item name="android:windowBackground">#color/transparent</item>
<item name="android:gravity">center</item>
</style>
Second and Final Solution :
I finished by using the DatePickerDialog.THEME_DEVICE_DEFAULT_LIGHT that works just fine. We didn't use a lot of styling so it was ok.
You have a "bug" in your themes.xml or styles.xml material design support library is not working properly with dialogs.
So remove the specific dialog code or separate it in different versions.
Trying to explain a little bit further.
Generally when we extend the original application theme we have an themes.xml and/or styles.xml files under the values folder. In there code you will find something like these:
Application theme:
<style name="MyTheme" parent="#style/Theme.AppCompat.Light.DarkActionBar">
<!-- ... other styling values ... -->
<!-- Dialog attributes -->
<item name="dialogTheme">#style/MyTheme.Dialog</item>
<!-- AlertDialog attributes -->
<item name="alertDialogTheme">#style/MyTheme.Dialog</item>
<!-- ... other styling values ... -->
</style>
Custom dialog theme:
<style name="MyTheme.Dialog" parent="#style/Theme.AppCompat.Light.Dialog">
<!-- some styling values here -->
</style>
What needs customization is the parent of the MyTheme.Dialog this Theme.AppCompat.Light.Dialog does not work properly for all android versions it may work for Lollipop but does not work for KitKat, or the opposite.
With a simple run of the app in each platform you can easily find out in which version it works.
Then you can create a different folder for values-v21 and define the parent of the dialog accordingly, so that it work for both versions.
You can apply some other workarounds regarding the customization of the style, in order for this to work.
If you would like further research, or theme customization ideas take a look at the source of android theme.xml here.
It may be late but will help.
You have to add transparent background of you dialog. Here is how you can do this:
DatePickerDialog dpd = new DatePickerDialog(this, android.R.style.Theme_Holo_Dialog, reservationDate, 2014, 1, 1)
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
};
for me it didn't help to set the window background to transparent, this made all my datePicker dialog with transparent not only the ugly border.. :(
what helped me is to set also the regular background to the color I wanted and the windowBackground to transparent.
this is my style:
<style name="pickerDialogDark" parent="Theme.AppCompat.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:background">?attr/dialogBackground</item>
<item name="android:textColor">#color/colorSimpleGreen</item>
<item name="colorAccent">#color/colorGreen</item>
<item name="colorPrimaryDark">#color/colorBlack</item>
<item name="android:textColorSecondary">#color/colorSimpleGreen</item>
<item name="android:headerBackground">?attr/dialogBackground</item>
</style>
Add a new style in the default style (not style-21)
<style name="Your style" parent="#android:style/Widget.DeviceDefault.DatePicker">
<item name="android:textColor">#color/app__primary_color</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:gravity">center</item>
<item name="android:layout_gravity">center</item>
DatePickerDialog dialog = new DatePickerDialog(mContext, android.R.style.Theme_Holo_Light_Dialog_NoActionBar, mDateSetListener, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DATE));
dialog.getWindow().setBackgroundDrawableResource(R.color.transparency);
dialog.show();

Change Dialog Theme for every Dialog

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

How to create a Dialog with a Light theme? [duplicate]

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.

Setting Application theme textColor to white causes Context Menu item text to be white (invisible)

Ok, this is driving me bonkers. To skin my app, I set the following in my theme:
<item name="android:textColor">#FFFFFF</item>
All the text in the app turns white, unless I manually override it in the layout xmls. Great, yay, easy peasy. EXCEPT that the text in my menu options for context menus (off of lists and such) have also decided to become white.
This is not so great, since it is hard to read white on white. I have tried a variety of solutions, including searching for how to change the text color of a context menu (no dice)and creating a textAppearance item in my theme. The last solution didn't change all the textfields in my app, which was frustrating.
So, any suggestions? Hopefully my dilema is clear.
In your styles.xml try overriding the textViewStyle instead of just ALL textColor attributes:
<style name="Theme.Blundell.Light" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/background_light</item>
<item name="android:textViewStyle">#style/Widget.TextView.Black</item>
</style>
<style name="Widget.TextView.Black" parent="#android:style/Widget.TextView">
<item name="android:textColor">#000000</item>
</style>
You could even take it one further and just override the color for a certain view, like buttons:
<style name="Widget.Holo.Button" parent="#android:style/Widget.Holo.Button">
<item name="android:textColor">#FFFFFF</item>
</style>
<style name="Theme.Blundell" parent="#android:style/Theme.Holo.NoActionBar">
<item name="android:colorBackground">#android:color/transparent</item>
<item name="android:buttonStyle">#style/Widget.Holo.Button</item>
</style>
If your inspired to do any more theming check out the Android source it's the best place to realise what you can and can't do!:
https://github.com/android/platform_frameworks_base/tree/master/core/res/res/values
Use this:
parent="Theme.AppCompat.Light.DarkActionBar"

Categories

Resources