Picture Example
I've tried to add this prefix and also added it to the AppBarLayout, but it doesn't work.
<item name="android:elevation">0dp</item>
Any help is appreciated, Thanks
Try something like in your style
<item name="android:windowContentOverlay">#null</item>
Check this Remove shadow below actionbar
On Android 5.0 this has changed, you have to call setElevation(0) on your action bar. Note that if you're using the support library you must call it to that like so:
getSupportActionBar().setElevation(0);
Related
I recently started working with PreferenceFragmentCompat and MaterialComponents and noticed that in Dark mode, Dialogs generated by preferences like ListPreference always have that weird grey android background no matter how many background attributes I change in the style.
(source: pocketnow.com)
This I've tried:
<item name="android:windowBackground">#color/colorPrimaryDark</item>
<item name="android:colorBackground">#color/colorPrimaryDark</item>
<item name="android:colorBackgroundFloating">#color/colorPrimaryDark</item>
I've also tried with android:background and worked but it brokes everything.
So I investigated a bit in-depth at elements like EditTextPreferenceDialogFragment and most of them create and show an AlertDialog instance in the same function of PreferenceDialogFragment without any possibility to change its style.
Or at least that's the conclusion I've come to after some research on the subject.
My question is, has anyone found a workaround for this? Am I doing something wrong? Cause I would like to have those dialogs matching my app theme even if it's just the background color.
Btw, sorry if it has been already answered before. I also searched in here but found nothing and similar answers for different problems without results. Thanks.
Found it! After reading more the AndroidX package found that by default the AlertDialog.Builder retrieves a default theme from an attribute when no specified in the constructor. You can see it here
So a solution would be to add a specific theme for dialogs in the activity like this:
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<item name="alertDialogTheme">#style/AlertDialogCustom</item>
</style>
And then you setup your dialog theme like:
<style name="AlertDialogCustom" parent="Theme.AppCompat.Light.Dialog">
<item name="colorAccent">#FFC107</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:background">#4CAF50</item>
</style>
And this is the result:
Bonus tip: If you want to also setup the default theme for
MaterialAlertDialogBuilder you must change de attribute
materialAlertDialogTheme
So, this question is kind of an extension of this question, I solved the issue with the headerBackground but I realised that I had manually set the theme of my DatePicker in my layout using android:theme="#style/State0DatePickerTheme. But when I removed that line from my XML, the day selector just turned back to white (my accent colour defined in my base theme). Any thoughts on why this is, or how to fix it?
For my purposes, I need to have the theme for DatePicker set in my styles.xml with android:datePickerStyle because I'm setting my theme dynamically in my onCreate() and I can't change the theme of the datePicker in java (at least not that I'm aware of).
So, I figured out how to fix it, I simply created a new theme (which I called State0HistoryTheme) and then made its parent State0BaseTheme and applied that theme to my entire activity in my onCreate() using setTheme()
This is what my State0HistoryTheme looks like for those curious:
<style name="State0HistoryTheme" parent="State0BaseTheme">
<item name="colorAccent">#color/state0Dark</item>
</style>
This was able to override the colorAccent that I had set in State0BaseTheme
I am working on an android app that receives content from another apps sharing it via an android intent. I did the intent filter to receive the shared content into the app, but I saw that apps like Pocket made that without leaving the original app with an overlay over the app and I don't know how to do that. Does anyone know how to do that or give me some hints?
Start activity that has transparent theme with following attributes (test this on API 18 for bug):
<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:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
Set child elements as you desire, as you would do in normal activity.
After receiving your Intent, you should start a Service which create and attach your View/ViewGroup on the Window. This will allow you to keep the calling application in foreground.
To create a floating overlay take a look here: http://www.piwai.info/chatheads-basics/
I would look at the WindowManager Class:
http://developer.android.com/reference/android/view/WindowManager.html
Here is a link to a question that better explains what it is:
What is WindowManager in android?
In theory a simple thing. I would like to change the background color of toast (android:minSdkVersion="14" android:targetSdkVersion="18"). What I did? I've found the Theme.Holo.Light definition which I use as parent for my own style:
Theme.Holo.Light definition
Next I've found:
<item name="android:toastFrameBackground">
Nest I wanted to modify it:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="android:Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarStyle</item>
<item name="android:toastFrameBackground">#android:color/holo_blue_light</item>
etc.
While for Action Bar it works without problems, for toastFrameBackground eclipse displays always:
error: Error: No resource found that matches the given name: attr 'android:toastFrameBackground'. styles.xml Android AAPT Problem
I've even set it to the original version (just copied from original theme definition):
<item name="toastFrameBackground">#android:drawable/toast_frame</item>
Hoping it should work. No way.
When I click ctr+space Eclipse it seems not to see toastFrameBackground. Why? I've checked some other items from original theme definition and some seems to be visible, while others no.
Any idea? help?
I've spent 3-4 hours and nothing... Probably I will keep the original toast background color as it seems it's not worth to fight but I would prefer to understand deeper the mechanism. Why I don't have an access to the item it seems I should have an access.
That's because toastFrameBackground is not exported and did not make to public.xml, which means this attribute is not available for non-platform/third-party applications.
However, you may want to see https://stackoverflow.com/a/9903465/1893766 for what you are trying to achieve.
First excuse me for my english.
Im designing a theme (With HoloEveryWhere) and im trying to style default spinner.
The problem is that the spinnerStyle is not working. I'm testing with this layout.
<Spinner
android:id="#+id/spCountry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/etPhone" />
And im using this for my theme.xml..
<item name="android:spinnerStyle">#style/Coloquium.Spinner.Ruby</item>
and in styles.xml
<style name="Coloquium.Spinner.Ruby" parent="#style/Holo.Spinner.Light">
<item name="android:background">#drawable/spinner_holo_white</item>
</style>
The problem is that the spinner style is never applied (Others styles like edittextstyle or buttonstyle works fine), the background never change, But i tried this style as spinnerItemStyle and work fine, but spinnerItemStyle is the inner view, and i want to style the outer, the spinner.
If i set background directly in the layout node, the background change fine, but i need to set spinnerStyle for all spinners in the theme, not in layout.
I test a lot of post looking for a solution without success.
The solution is:
HoloEveryWhere appear use "spinnerStyle" and not "android:spinnerStyle".
But really... I can't find the HoloEveryWhere documentation about this. :S