ActionBar dissapears when using sepcified resource folder - android

I am writing app with android:minSdkVersion="14". Everything went fine until I tryed to add support for tablets.
When I created values-sw600dp folder and copied there the default dimens.xml file from values folder and tried to run the app on tablet, it started behave differently even when those dimensions file were identical.
ActionBar was gone, getActionBar() started to return null, EditText fields are orange framed instead of that blue underline, whole app design now looks like its on android 2.0.
On smaller devices where it still used default values folder everything is ok.
For testing, I tried to lower the 600 threshold (in values-sw600dp) to 300 to force this folder to be used even on smaller devices and result was same. ActionBar gone etc...
Sorry for english and thank you for answer

Ok I found solution to my problem. I accidentally coppied line:
<style name="AppBaseTheme" parent="android:Theme.Light">
into my dimens.xml file in folder values-sw600dp, which caused application to use Theme.Light instead of my default theme Theme.Holo.Light.DarkActionBar in folder values-v14. I donĀ“t know how it got there but I am glad I found it.

Related

How can i change icon.png depending on app theme (day/night) android kotlin

I have a logo on my splash screen and two files:
logo_night.png and logo_day.png
How can i change this logo that will change depending on the theme of the app using these two files?
The usual way is to use a night resource qualifier, so if you're using a dark theme it pulls the named resource from the equivalent night folder if it exists there.
You have three basic options with this I think:
just call them both logo.png, but put one version in drawable and the other in drawable-night. That way, whenever you refer to #drawable/logo it'll pull the correct version depending on the theme. If you have multiple density versions, in drawable-hdpi etc, you'll need them in drawable-night-hdpi etc. (the qualifier order matters)
if you're making your splash in the usual way, where you create a splash drawable with a background layer and your logo drawable on another layer, you could just make a night variant of this instead (in drawable-night). Each version can explicitly refer to logo_day or logo_night and you can just keep those PNGs in the normal drawable folder
or you can make a night version of your splash theme, and explicitly set the background to the dark version of your splash drawable instead. Both your splash drawables can stay in the normal drawable folder
So basically, something's gotta get a version in a night-qualified resource folder, so it can provide an alternative resource for dark mode. It's up to you which resource in that hierarchy you want to make the night version of (or you can do it for all of them if you want).
Also bear in mind that your splash theme (if you're doing it that way) follows the system's dark mode setting. If you're implementing a toggle in your app, and you set it to dark mode, the splash will still show up as the light variant if that's what the device is set to. That theme is set before your app starts and gets to work out if it should be in dark or light mode
Since you are using png format. You can call .getTheme() on context object to get current theme, make an if statement to decide which png to show.
For example in activity you can get theme by just calling getTheme() because this.getTheme() is implied.
Other possibility is to switch to vectors where you can define different colors for different themes they will change automatically when user changes theme. This is probably better and more scalable solution. You can find much more details here.

Image recognised in Android Studio but invisible on Phone

My Images are being recognised like so (Look at the left):
However when I run the app on my phone the images just become invisible.
This just happened all of a sudden, I don't believe I changed anything other than copied other images into the folder, it seems like there is no consistency.
Also, I tried moving the icon images into the mipmap folders, specifically mdpi.
Still no luck. (So drawables and mipmap are broken?)
Any ideas?
Have you changed the theme recently?
If you have a white navigation bar but are using a dark theme, then the icons will show up white, regardless of the color you set them to.
So they are still there, but just the same color as the background.
Try changing the theme to a light theme.
If this works, but the rest of the app such as the Toolbar is not the correct color/theme, you can always override the theme for the Toolbar:
app:theme="#style/Dark.Overlay"

How to create resource folder for android 21 api and higher?

I can create folders with names values-21, values-22. But It will produce code duplication. Can I create something like values-21>= ?
For API 21+, you would have res/values-v21 . Take a look here http://www.metaandroid.com/question/primary-dark-color-android-under-api-21/
For this you need to have 2 values folder.
One that exist by default, and another, u have to create in your res folder and name it values-v21.
In the default values folder, in styles.xml, use theme other than Material theme And in the styles.xml of values-v21 folder that you created, use Material theme.
Android phone will automatically pickup the styles.xml which it support. If the phone supports Material Design (Lollipop devices), your app will use material theme (values-21 folder).
if it doesnt (in phones running older android versions), the default values folder will be used.
For more reference go click here

Render theme in mapsforge

I use mapsforge in my app. I want to use different theme for create different font size. I create different them and save in asset folder and i change my theme with below code but the program cnanot load true theme! I want when click on A button, load xhdpi but when click on this, load a theme with vry small font!
File f=new File(destination,"xhdpi");
mapView.stRenderTheme(f);
in xhdpi theme, i set big font(30) but when i run this code theme change to small font and i dont know, the program of where load this theme! :D
and in the last, i think, mapsforge or my app use a default theme for changing theme but im not sure and i dont know where is the problem!
Thanks for advise and your help.
Try this:
mapView.setTextScale(3); // default scale size is 1
if it works as works for me , you can give scaling as an option to user!

Default values for Honeycomb

Is there a list of default values for Honeycomb text sizes so I can use them in my application for consistency with other built in applications? I tried to apply Holo theme but this has no affect for text sizes, they are as small as on the phone.
There is no "Holo theme" for phones today, as Honeycomb is only for tablets.
You are welcome to examine the Honeycomb styles resources in your SDK to see what various text sizes are listed as. I see many listed in res/values/styles.xml (e.g., dialog title bars are 18sp). You might start with the Theme.Holo definition in res/values/themes.xml, find the item you want, then look up the value in res/values/styles.xml.

Categories

Resources