I have the following problem : I want to use Theme.NoTitleBar.Fullscreen for my application parrent theme, but with this theme the number picker looks in the older way (with "+" and "-"), but I want to looks like the new way (with the blue dividers). Is there a way to achieve this? It will be sad (and I will lose a lot of time) to write my own picker only, because of the theme ? I will be glad if someone has simple solution. I google it but I insist to not change the style, because the application was always with this style and it will be strange to change the whole style only for that.
Thanks in advance.
P.S. I try not to make this theme parent theme and just to copy
<item name="android:windowFullscreen">true</item>
<item name="android:windowContentOverlay">#null</item>
this properties in my theme, but then application is not in full screen i.e. not working properly (like with make Theme.NoTitleBar.Fullscreen parent theme ) .
P.S.2 There is Theme.Holo.NoActionBar.Fullscreen and I thing it should work, but I'm not sure what is the difference between it and Theme.NoTitleBar.Fullscreen.
I will be glad if someone enlighten me.
Related
I am a student trying to learn app development with android studio. For my first project, im just building a basic calculator app. I have stumbled across a problem that I couldnt solve and didnt find a helpfull post about. It occurs when I trun on dark mode on the virtual device. Here are 2 pictures showing what happens.
How it looks with dark mode
How it is supposed to look
My activity_main.xml consists of some buttons that all have the same style and a TextView.
I left all the other files untouched. Id love some advice on how to fix this. Thanks for reading!
You are most likely using the following default DayNight theme in your themes.xml file (values/themes/themes.xml)
<style name="Theme.MyApp" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
If you don't want things to change in night mode, you can change that to use the Light theme instead
<style name="Theme.MyApp" parent="Theme.MaterialComponents.Light.DarkActionBar">
and delete the themes.xml (night) file if it exists. There is some extra info about these options here
there are two themes : night and not night check in IDE Design tab you can view how it looks in both click the circle in pane where design is displaying it displays Not Night and Night whatever theme you are using it will affect because of these two modes, by default IDE shows not night
To show screen same in both modes you need to change some settings like in your activity_main.xml at root layout change background to #color/white and see what happens it should be sorted out since your button colors are dark ...the text Placeholder color needs to be changed accordingly
<LinearLayout
background=#color/white
other layout etc to follow
Anyone can help me?
I'm developing the Light and Dark theme function in the android app, everything goes fine, but the background of Recyclerview shows incorrectly.
The root background of xml file is White color and I didn't set background for recyclerview in xml. However, after changing from Light to Dark or Dark to Right=> background of recyclerview automatically change to a strange color(this color didn't see in my color.xml resource). I tried to set background of Recyclerview to #null or transparent in code and xml file as well but the background of recyclerview didn't remove that strange color.
So anyone knows exactly the reason why, please help me and much appreciated. Thanks
enter image description hereenter image description here
I am guessing you are using the DayNight Theme. If so you should have to themes.xml folder in res, one is called as mentioned and the other is with the extension (night). There you can define a color in both xml files. It has the same name but different color values like this:
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<item name="colorPrimaryDark">#ffffff</item> <!-- you normally shouldn't hardcode color -->
</style>
The same for your folder (night):
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<item name="colorPrimaryDark">#000000</item> <!-- you normally shouldn't hardcode color -->
</style>
The idea is to have one attribute name that contains 2 colors and takes the correct one if needed. For futher understanding I suggest to take a look at this reference to get more familiar with Themes and Styles. Now you set up your Day and Night files properly, you can implement it by using it in your recyclerView as follows:
android:background="?attr/colorPrimaryDark"
Another tip is to make custom colors in multiple colors.xml files to make them for more unique use. In this case colorPrimaryDark effect your whole app. It is also suggested to modify layouts and the visuals of widgets to take effect only on those. (e.x. your recyclerView). In my app I used colorPrimaryDark for all Background (that should be same for more clean design). I think you get the keypoint. Take a look around the net and this forum and you will find your final design strategy. Cheers! :)
I created an activity with a custom titlebar and a button in it, which is extended by all other activites. It works well so far, but when I use an activity whith theme.dialog the titlebar is not shown correct. There is a padding to the left and right of the title and height is limited to 25, I guess.
So I tried the same to the theme.dialog windowTitleSize as I did to the theme. But it showed the same result as if I just change only the title of the normal theme - a padding to the left and right and the wrong height.
After a lot of googling I found at least one solution that works here on stackoverflow. Unfortunately it fixes the padding for the titlebar at runtime with Class.forName() and getField(). I could change the height of the titlebar with layoutParams the same way, but would like to set it all up in xml.
I browsed themes.xml in the ..data/res/values but could not find where the limitation of the layout is set. Finally I tried to extend the normal theme and create a dialog myself. That brought me to Widget.PreferenceFrameLayout and the following errors in my xmls:
In styles.xml "no resource found..." on all "...android:border..."
<style name="MyPreference">
<item name="android:borderTop">20dp</item>
...
</style>
And in themes.xml "no resource found...android:preferenceFrameLayoutStyle"
<style name="MyThemeDialog" parent="android:Theme">
...
<item name="android:preferenceFrameLayoutStyle">#style/MyPreference</item>
...
</style>
How am I supposed to use the given themes and styles the right way to set up the titlebar in theme.dialog?
-----edit-----
I recognized, that the mentioned attributs are not available in the attrs.xml of api8, so sorry for the hasted asked question. Sometimes I just can't see the forest because of all the trees.
Thanks in advance for your help,
Christel
I'm trying to make a custom titlebar for my first Android application.
While I can find lots on the web about how to make them so you can change colours etc, I want my titlebar to look the same as the "standard" titlebar, but with a button that I can configure. This means copying the device's currently active themes to be able to style it in exactly the same way.
Not all devices simply use a gradient in the titlebar style, so adding a gradient (as suggested in other SO questions) doesn't really make sense.
Does anyone have any pointers how to read the style information?
try to extend an existing theme e.g.
create your own style which can ofcourse extend from existing from an existing theme. change the windowNoTitle to true.
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="noTitleBarStyle" parent="android:Theme.Black">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">#color/darkGrey</item>
<item name="android:colorForeground">#ff3333</item>
</style></resources>
or try to do it runtime as discussed here
Android - change custom title view at run time
I hope this helps.
tl;dr: White text style in app theme being picked up by search dialog, making search text invisible.
I'm struggling mightily with what seems like a trivial issue.
My app is using a dark background, and I've tweaked the text color to be brighter than the standard gray using #EEEEEE.
I've implemented a Search Dialog (pre-Honeycomb) and it works well, but the text in the search dialog picks up the same #EEEEEE so it is essentially invisible. Even the context menu displayed when I long press the search text picks up #EEEEEE, so the text there is invisible as well.
I'm tearing my hair out, and I'm running out of hair.
Style:
<style name="master" paret="#android:style/Theme.NoTitleBar">
<item name="android:textColor">#EEEEEE</item>
<item name="android:windowNoTitle">true</item>
</style>
Manifest:
<application android:icon="#drawable/icon"
android:label="#string/app_label"
android:theme="#style/master"
android:hardwareAccelerated="true"
android:debuggable="true">
The attribute android:textColor is not meant to be used inside theme styles, it is primarily useful in widget and text appearance styles.
If you want to change the general text colors through a theme, use instead the android:textColor* family of attributes. There are quite a few of them, and different Views use them differently, so it takes a bit of experimentation (or careful studying of the Android source code) to to get it all right. The android.R.attr documentation lists them all. Look for the attributes that begin with textColor....
To get you started, try this theme, it will behave better by not affecting the Search Dialog colors at all, which seems to be what you want. By the way, you don't need to set android:windowNoTitle to true in your theme as your parent theme does that already:
<style name="master" parent="#android:style/Theme.NoTitleBar">
<item name="android:textColorPrimary">#EEEEEE</item>
<item name="android:textColorSecondary">#EEEEEE</item>
<item name="android:textColorTertiary">#EEEEEE</item>
</style>
I got into the same problem as you. I've looked around for a solution but it seems that you just can't change the textColor of a dialog. My solution was creating a custom dialog based on this tutorial: http://blog.androgames.net/10/custom-android-dialog/
I extended this a lot based on the Android source code, always using the same method names etc to make it a bit easier.
It is not ideal, but as far as I know it's the best option...
EDIT: for your problem there might be a simpler solution: don't put the textColor into the theme, but put it in a style. I don't know how you're styling your app but I'm usually creating a "master-style" which all the others inherit from (direct or indirect). You could then put the textColor in there so all your standard dialogs will still have the standard textColor.