I'm using Christophe Versiuex's HoloEverywhere library in concert with ActionBarSherlock to display an ICS looking app on Gingerbread phones. The Theme.HoloEverywhereDark.Sherlock theme works great. But when I try to change the theme to Theme.HoloEverywhereLight.Sherlock, all the text changes to dark text, but the Activity backgrounds stay dark.
All I'm doing is:
setTheme(R.style.Theme_HoloEverywhereLight_Sherlock);
setContentView(R.layout.mylayout);
in the Activity.onCreate() method.
In looking at the code, it defines:
<style name="Theme.HoloEverywhereLight.Sherlock" parent="Theme.Sherlock.Light">
<item name="android:windowBackground">#drawable/background_holo_light</item>
.
.
.
so it looks like it should work.
Has anyone else used the Light theme and gotten a light background?
Thanx.
I figured this out. I was doing:
super.onCreate(savedInstanceState);
setTheme(R.style.Theme_HoloEverywhereLight_Sherlock);
setContentView(R.layout.mylayout);
when I should have been doing:
setTheme(R.style.Theme_HoloEverywhereLight_Sherlock);
super.onCreate(savedInstanceState);
setContentView(R.layout.mylayout);
setTheme() needed to be called before super.onCreate(). Now the light theme works like a charm.
Related
This is the home screen of my app. I have used Drawable and Color resources in the design. Now I want to have multiple color sets (for the parts with cyan color) so user can change them at run time. I searched a lot, but they don't fit my case.
Note that I want just the cyan colored parts to change. I know I can change all the TextView styles using style attribute, but I just need certain views get certain drawables or colors as background.
I found a solution here but I cannot use it because it needs the min sdk higher than 21 while mine is 16.
Home screen
You can easily set theme like this:
public void onCreate(Bundle savedInstanceState) {
setTheme(R.style.your_theme);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity)
}
Define your style in values/styles.xml like so:
<style name="AppTheme.MyTheme" parent="AppTheme.NoActionBar">
<item name="colorPrimary">#color/primaryColorCyan</item>
<item name="colorPrimaryDark">#color/primaryDarkColorCyan</item>
<item name="colorAccent">#color/secondaryColorCyan</item>
</style>
And then call setTheme(R.style.MyTheme) before setContentView() in onCreate() method. setTheme introduced in API LEVEL 1.
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.
Like a lot of people, I would like to use a custom title bar in android but also use the Holo theme. I've seen a lot of posts recommending using Theme.Holo.NoActionBar but it still gives me the same error as when I change my custom theme to use Theme.Holo. I want to resolve once and for all, is it possible to use a custom title bar like this:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.activity_main);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,R.layout.custom_title_bar);
which seems to be the most common way to do it.
Well you can create another element layout which looks like title bar for you and in the current activity you can set requestWindowFeature(Window.FEATURE_NO_TITLE)
This way you get the holo theme aswell as custom title. This is commonly used practice in this scenario.
you can define parent="#android:style/Theme.Holo"
then just disable the windows action bar
like this
<item name="android:windowActionBar">false</item>
in theme.
It's working for me...
I am using Holo dark as the theme of my app. However, there is part of it where I wish to use the EditText from holo light as the background is light in this part. I have tried doing it in themes. It worked when I did something similar for a button (we wanted to use the gingerbread style button):
<style
name="Theme.Banks" parent="Theme.Sherlock.ForceOverflow">
<item name="android:buttonStyle">#android:style/Widget.Button</item>
</style>
I tried doing the same with android:editTextStyle, but it does not affect the drawable. That is handled by the attribute android:editTextBackground. Looking into the code, I cannot just override this and point it at the light theme because it references a private drawable:
This is from themes.xml in the SDK:
<item name="editTextBackground">#android:drawable/edit_text_holo_dark</item>
So my question is how to do this?
Another use case might be wishing to use the EditText from gingerbread.
Any ideas?
You could grab the drawables that you need out of the the sdk res folder and include them with your own project then reference your own copy of the holo light drawables for that one EditText.
Seems inefficient, but I am not sure of any other way to get around your style issue.
I've got a custom layout I want to use as the titlebar of my android app. The technique found (linked at the bottom) works, but the system titlebar is displayed before onCreate() is called. Obviously that looks pretty jarring, as for a moment the system titlebar is shown, then my custom titlebar is shown:
// styles.xml
<resources>
<style name="MyTheme">
<item name="android:windowTitleSize">40dip</item>
</style>
</resources>
// One of my activities, MyTheme is applied to it in the manifest.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.my_activity);
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.my_custom_header);
}
I could always hide the system titlebar and display my own in-line perhaps with each and every layout, but, that's not very friendly.
Thanks
http://www.londatiga.net/it/how-to-create-custom-window-title-in-android/
I think it's a framework limitation. I had the same problem in some of my applications and the ultimate solution was for me to tell the framework I didn't want a title bar at all and then create my own in my layouts. The include directive made it bearable for me, e.g.:
<include layout="#layout/title" />
When I used requestWindowFeature(Window.FEATURE_NO_TITLE) in my activities, I would have the same issue, I'd see the system title bar briefly while the activity was being build when it first loaded.
When I switched to using a theme to tell the framework I didn't want a title, the problem went away and I now see my own title directly on first load. The styling is easy for that:
<style name="FliqTheme" parent="#android:Theme.Black">
<item name="android:windowNoTitle">true</item>
</style>
I know this doesn't apply to your issue with the custom title, but like ptc mentioned, if you move your custom title into style/theme definitions (which you do by overriding the system title styles in your theme), I think you'll be on the right track.
The same problem happened to me today when I was trying to custom the title. I solved it by set the android:theme to android:style/Theme.NoTitleBar in the AndroidManifest.xml, and call setTheme() to the actual theme I want in my activity's onCreate callback function.
Try creating a custom theme style in XML and then set your activity's theme attribute in the AndroidManifest.xml file.
http://developer.android.com/guide/topics/ui/themes.html#ApplyATheme
The method through setting android:theme does not work for me, I have made it by adding the following code in onCreate() of my Activity subclass:
getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);