Changing Theme in Android Studio - android

I just noticed that the default theme when I am creating an android application in AS is Theme.AppCompat.Light.DarkActionBar which, for me, is very plain.
My question is how to use Holo Light Theme?
Because when I tried in giving me an error underlining the statement.
Can someone help me?

If you could show us what you're doing in your styles.xml file that isn't working it would be very helpful.
Otherwise, I think you're looking for something along the lines of <style name="AppTheme" parent="android:Theme.Holo.Light">. The key is that this is an android provided theme and is found using android:Theme

Related

What is a theme and how do I know if I have the "correct" one?

In my current project, when I select the Design tab in Android Studio 2.2.2 for a particular layout I get an error that says
Missing styles. Is the correct theme chosen for this layout?
and it goes on to say
Failed to find style 'textEditSuggestionItemLayout' in current theme
(42 similar errors not shown)
But, the actual layout renders OK in the Designer and at runtime.
There are lots of other S.O. posts on this, such as here and here and most of the answers seem to involve clearing the caches and restarting Android Studio, or selecting a different theme from the dropdown. I I have tried the first one but it didn't help. I haven't tried the second one yet because I don't really understand what a theme is.
Questions:
The error implies that there's an error in the theme itself. What
is that? Is the theme file part of my project, i.e., is it one
that I should be creating, editing, and that gets built and shipped
as part of my APK or is it only used in the developer IDE?
If I select a different theme from the dropdown how do I know what the
"correct" one is?
Since my project builds and runs OK as is, can I just ignore these
errors? In other words are these errors in my code or just a
problem with the development environment?
Edit: Some additional information after responding to comments, below:
The only place the string 'theme' is used in my manifest is
android:theme="#style/Theme.FullScreen"
... and FullScreen is the theme specified in the dropdown.
I did a search in my project for the string "textEditSuggestionItemLayout" and Android Studio found no occurrences of it.
If you've recently updated AS or any of its components, then try to 'Invalidate caches & restart'.
Else, try choosing AppTheme from the Design tab or change it to AppTheme from the default one. Choose the one that conforms to your parent app theme in your styles.xml.
The cause of the error could be anything from malfunctioning IDE to selecting a theme not mentioned in your styles.xml (most likely).
You could do a project-wide search for textEditSuggestionItemlayout, or the other styles that it claims to miss.
These are either in your own res/values/styles.xml and/or res/values/themes.xml files, or they are provided within the SDK, which is why you see some suggestions to uncheck 'Automatically Pick Best' and pick a version you have installed. In some cases, the latest API version's rendering tools don't work.
As an example, if you have your style set at Theme.Holo, but you are using the AppCompatActivity, you'll get a rendering error that you must use a Theme.AppCompat (or descendant). These themes are changeable from the dropdown of the design editor.
You can see what themes/styles are applied to your Activities within the AndroidManifest.xml.
res/values/styles.xml
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#color/PrimaryColor</item>
<item name="colorPrimaryDark">#color/PrimaryDarkColor</item>
<!-- Customize your theme here. -->
</style>
AndroidManifest.xml
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme">
Note: android:theme= and #style/
If you are still missing themes, then you may be missing some dependency, such as
compile 'com.android.support:design:<your_version_here>'
If your code runs fine, then sure, ignore it, but I think getting the layout designer working again shouldn't be ignored.

Android Themes and styles.xml

(1) I am confused with the themes in android.
For example android:Theme.Material.Light and Theme.AppCompat.Light.
Also Holo light and dark themes.
I don't understand when to use what. Can someone explain me the differences of these android themes?
Need a good explanation about these themes so that I can understand how this works in my style.xml.
(2) why there are prefixed and non prefixed attributes in style tags.
<item name="colorPrimary">#3F51B5</item>
<item name="android:colorPrimary">#3F51B5</item>
when to use prefix?
Can someone explain this?
The important thing to note about these themes is that not every version of Android will support them. Thus, you may want to use different themes depending on which version of Android your application gets installed on. Derek Banas had a great video on styles and themes:
https://www.youtube.com/watch?v=W3xHIN15hP8
I'm not the most knowledgeable about styles, but I'll give it a shot. I believe that "android:colorPrimary" is used when you are overriding an attribute in an already defined style. I'm not the most knowledgeable about styles so I will lead you to the documentation page that I found that seems to cover this topic fairly well:
http://developer.android.com/guide/topics/ui/themes.html
Here are some references for further reading
https://plus.google.com/+AndroidDevelopers/posts/JXHKyhsWHAH
https://plus.google.com/+AndroidDevelopers/posts/AV2ooBWY1iy

Android number picker style

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.

No resource found that matches the given name '#android:style/Theme.MyStyle'

I'm new to android programming (developing on Android Studio 0.8.11) and I'm having issues applying a custom theme to an ActionBar.
My goal is to create a complete custom actionBar with different colours and resources. My min SDK is 16.
Here is the example theme definition in the /res/values/styles.xml:
<style name="Theme.MyStyle" parent="#android:style/Theme.Holo.Light.DarkActionBar" >
<item name="android:actionMenuTextColor">#00FF00</item>
</style>
I'm trying to applying this to all the app with the following line in the manifest xml:
<application> [...] android:theme="#android:style/Theme.MyStyle">
</application>
However when I try to lookout for "Theme.MyStyle" the auto-completion seems not to find it. In fact that part is reded out and the compiler says "No resource found that matches the given name '#android:style/Theme.MyStyle'" .
I'm just trying to figure out how to correct applying a theme, all the guides found even on android developer makes the theming easy but I can't find what's wrong!
Any tips? Thank you very much!
#android:style is for predefined android styles
Change this
android:theme="#android:style/Theme.MyStyle"
into
android:theme="#style/Theme.MyStyle"

Properly set SeekBar style for Holo and pre-Holo APIs

After setting SeekBar with Holo style, I got warning that it's not supported pre-Holo APIs.
If I leave it this way, will this crash the app or pull pre-Holo style anyway? It does not crash on the emulator and I don't have 2.3.3 device.
The reason for asking his is odd behaviour. I tried to manually set style for Holo and pre-Holo using res/values-v11/ directories and placing styles.xml in each and setting the style of SeekBar to style="#style/settings_seekbar" .
Style for API 11+ looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.Holo.SeekBar</item>
</style>
and style for APIs older than 11 looked like this
<style name="settings_seekbar">
<item name="android:seekBarStyle">#android:style/Widget.SeekBar</item>
</style>
So it looked like this would work. But on either device with Android 4.0+, I don't see Holo's theme, but the old thick-yellow theme.
If this is the proper way of settings styles (in case the first solution will crash a device), where did I make a mistake thus Holo theme never appeared on newer devices?
It seems we can safely use a theme from the upper SDK because I found no indicators that it will ever crash the app.
If the theme does not exist, Android will use the appropriate lower-level theme.
The error we can see on the image is just a warning that UI will not look the same in the SDKs which do not support this theme.

Categories

Resources