Android: Theme.Holo.Light.NoActionBar vs Theme.Light.NoTitleBar - android

In res/values-v11/styles.xml, I can't use Theme.Holo.Light.NoActionBar because it was added in API level 13. Can I use Theme.Light.NoTitleBar instead, with no visual differences? As far as I can tell, they should both have a white background, status and navigation bars, and nothing else.

Theme.Light.NoTitleBar is slightly different. The easiest way to resolve this and stay compatible back to Honeycomb is to create your own style that extends Theme.Holo.Light, but removes the Action Bar. Just create a style with the following definition:
<style name="MyTheme" parent="android:Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>

As far as I know, the Theme.Light.NoTitleBar is based on older API level. You will get the style of Android 2.3. But Theme.Holo.Light.NoActionBar can give you the style of 4.0 or upper.

Related

Why do I need to use buttonStyle instead of android:buttonStyle with API level 16?

I was struggling to make a button style work with API level 16 (with API level 22 was working like a charm). I solved it replacing android:buttonStyle with buttonStyle
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- <item name="android:buttonStyle">#style/button</item> -->
<item name="buttonStyle">#style/button</item>
</style>
Now it works with both API levels, but now my question is:
Why is this happening?
Because
item name="buttonStyle"
is for support library compatibility which your current Theme supports. It is also used on defining other items like actionbar https://developer.android.com/training/basics/actionbar/styling.html
I suggest you define both of it to make it compatible to very wide range of devices

Material Design custom view theme

I am trying to have a default theme with a button. When I do this the button no longer ripples. I believe I need to set a proper parent on the btn_normal style but I can not find the appropiate theme.
btn_normal style works fine if I just apply it via a style to the button directly.
I have tried tons of parents and none of them have worked. Let me know if you have ran into this. Thanks.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:buttonStyle">#style/btn_normal</item>
</style>
<style name="btn_normal">
</style>
You should use RippleDrawable third party library. By that, you can give Ripple effect for Android 7+ version.

Mixing Android widget old & new themes

I'm starting my second Android app and find that I would like to mostly use HOLO dark theme for app.
EXCEPT for the EditTexts, I would prefer to use the old Gingerbread style ones (looking closer to iOS) with some rounded corner.
I'm a bit lost as to how I can achieve this. If anyone could drop some hints or links that would be HIGHLY appreciated
In your Theme:
<style name="myTheme" parent="android:Theme.Holo">
<item name="editTextStyle">#style/MyWidget.EditText</item>
</style>
<style name="MyWidget.EditText" parent="android:Widget.EditText">
<item name="android:background">#drawable/edit_text</item>
</style>
Now you can get the referenced drawable from Github(from the Gingerbread branch of the framework)

How can I have a drop shadow on my ActionBar (ActionBarSherlock)?

I am including my styled xml layout:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.Styled" parent="Theme.Sherlock">
<item name="actionBarStyle">#style/Widget.MyApp.ActionBar</item>
<item name="android:actionBarStyle">#style/Widget.MyApp.ActionBar</item>
</style>
<style name="Widget.MyApp.ActionBar" parent="Widget.Sherlock.Light.ActionBar">
<item name="titleTextStyle">#style/Widget.MyApp.TitleTextStyle</item>
<item name="background">#color/red</item>
<item name="android:background">#color/red</item>
<item name="windowContentOverlay">#null</item>
<item name="android:windowContentOverlay">#null</item>
</style>
<style name="Widget.MyApp.TitleTextStyle" parent="TextAppearance.Sherlock.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
<item name="android:textSize">21sp</item>
</style>
</resources>
Some of the search over internet suggests that use windowContentOverlay set to #null. But when i use it in the style xml it doesn't change anything. Can any one help what to do?
If you want to create a shadow below the ActionBar you have to set android:windowContentOverlay parameter on the application theme (in your code you are incorrectly setting it on the ActionBar style).
In your example it would be:
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="android:windowContentOverlay">#drawable/my_actionbar_shadow</item>
</style>
Using #null value removes the shadow.
This one line sets the shadow on ActionBar on Android 3.0 and newer. However if you are using ActionBarSherlock, it will not work as you expect. It would create the shadow on top of the window over the ActionBarSherlock on Android devices running system older than Android 4.0 (although ActionBar is present in the api since Android 3.0, ActionBarSherlock uses custom implementation for all Android versions older than Android 4.0).
To create the shadow below ActionBarSherlock you have to set windowContentOverlay parameter on the application theme (notice the missing android:).
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="windowContentOverlay">#drawable/my_actionbar_shadow</item>
</style>
Again, using #null removes the shadow.
Although this line works for ActionBarSherlock, it doesn't work on android devices running Android 4.0 and newer, no shadow is created under the ActionBar on such devices. So how to combine these two parameters to get the desired shadow under both ActionBar and ActionBarSherlock?
Use resource configuration qualifiers, in your case use platform version qualifiers.
In res/values/styles.xml use the second xml code. And in res/values-v14/styles.xml use the first xml code. Therefore the ActionBarSherlock version is used by default (for versions pre Android 4.0) and ActionBar version is used for Android 4.0 and newer.
Edit:
There is a bug in Android 4.3 (API level 18), android:windowContentOverlay does not work. It should be fixed in future release. In case you need it fixed in Android 4.3, you can find workarounds linked in the bug report.
As a previous answer did say use "windowContentOverlay" in the application theme and NOT the action bar style.
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="windowContentOverlay">#drawable/my_actionbar_shadow</item>
</style>
If you want a realistic shadow you can find one in the
"Your Android Folder"/platforms/android-16/data/res/drawable-hdpi/
ab_solid_shadow_holo.9.png and copy it to your drawable-hdpi folder then the end result is
<style name="Theme.Styled" parent="Theme.Sherlock">
...
<item name="windowContentOverlay">#drawable/ab_solid_shadow_holo</item>
</style>
In addition, above API21(Lollipop), you will need this in code, too.
getSupportActionBar().setElevation(0);

Need a definitive answer for styling Android ActionBar tabs

I've started my app with these two examples in mind:
http://code.google.com/p/iosched/
http://developer.android.com/resources/samples/HoneycombGallery/index.html
It currently has
minSdkVersion = 8 minSdkTarget = 11
set up in my manifest. I've tried everything I can think of, but can't seem to get the styling I want. I've accomplished a lot of styling, but one thing eludes me still...the tabs. I can't find any way to color them.
Now before I get too far, and before you tell me I missed something obvious, is it even possible to change the colors of the tabs on Android 3.1...or even 3.0 for that matter (the normally bright blue underlines)? It seems I can do most everything else...
I've looked all over for the answer. Including these places and many, many more...
http://developer.android.com/guide/topics/ui/actionbar.html
http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html
http://developer.android.com/resources/samples/ActionBarCompat/index.html
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
Android 3.0 ActionBar, changing colors
Android action bar like twitter sample
Android ActionBar tab style for Honeycomb
http://groups.google.com/group/android-developers/browse_thread/thread/983509d7261c54f4
If nothing else, this is a decent list of links for those looking...
Thanks
<style name="MyTheme.Light" parent="#android:style/Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarTabStyle">#style/customActionBarTabStyle</item>
<item name="android:actionBarTabTextStyle">#style/customActionBarTabTextStyle</item>
</style>
<style name="customActionBarTabTextStyle">
<item name="android:textColor">#android:color/white</item>
</style>
<style name="customActionBarTabStyle">
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">24dp</item>
<item name="android:paddingRight">24dp</item>
</style>
I don't think you can change the fine blue line colors.

Categories

Resources