Styling the ActionBar - android

Re this example from the Android developer blog
http://android-developers.blogspot.com/2011/04/customizing-action-bar.html
It says that to style the tabs on the action bar, to use a style like this:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBarView_TabView">
<item name="android:background">#drawable/actionbar_tab_bg</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
It references a parent style of "android:style/Widget.Holo.Light.ActionBarView_TabView" - which my project is unable to locate. I'm building against v3.2, with a min sdk of platform 8 (v2.2). I'm using ActionBarSherlock.
Am I doing something wrong, or is the sample code incorrect? What style can I inherit from?

Am I doing something wrong, or is the sample code incorrect?
The sample code was correct at the time and no longer is correct.
#Macarse has a blog post with the fix. Quoting Xav's comment on the related issue:
What is happening is that some styles, like WindowTitle are not public (you won't find them in android.R.style). You should not be extending non public resources. aapt used to let you do that but it was a bug which was fixed in platform-tools r6.

Related

How can I call the style of a new Library as parent in style.xml?

I am building a new library for Android and a demo project that I am using to test the library.
The library that I made has a style called Light and in the demo I am applying this style in Java using setTheme(R.style.Light) but I would like to replace it calling the theme directly in style.xml. What I have right now in the demo/res/values/style.xml is
<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">
and I would like to replace it with something similar to:
<style name="AppTheme" parent="myLibrary.Light">
I have tried with parent="#style/Light" but it's not working.
Does anyone know how I can do it?
To inherit styles from a library or your own project, declare the parent style name without the #android:style/ part. For example, the following example inherits text appearance styles from the support library:
<style name="GreenText" parent="TextAppearance.AppCompat">
<item name="android:textColor">#00FF00</item>
</style>
For more details
I found the solution,
My problem was that in my library I had different styles depending on the version of Android. For each version of Android my main theme was referred to different parents by mistake. I just changed the parents in my library making sure that they are referring to the same one and it fixed my problem. Now in my app I can refer to the theme created in my library without crashing the application.

Transparent Navigation Bar for Lollipop app?

What do I add to themes.xml to change the navigation bar to be more transparent? I can't find documentation for it anywhere. Thanks!
In your theme add the following line:
<item name="android:windowTranslucentNavigation">true</item>
Romain Guy has published a nice sample app that uses this API. Maybe it will help. (You might need to refactor some code since the project was originally written using the Android L developer preview).
Alex's answer is correct. You can use
<item name="android:windowTranslucentNavigation">true</item>
Another option is to use
<item name="android:windowBackground">#android:color/transparent</item>

android 4.2 how to get main color of current theme

In android 4.2 we have the possibility to select theme in device settings.
Default theme is equivalent to using #android:color/holo_blue_light as main color.
The question is what tag to use in order to get main color (blue_light, mint, mocha, raspberry) in my own style? If I use #android:color/holo_blue_light, when user switches to mint, part of user interface is in mint color (parts not modified by myself) and part in blue_light (parts modified by myself). I spent many many hours and it's seems there is no any solution.... Perhaps any workaround....?
I even tried to analyse Android styles and theme sources and still no answer:
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/themes.xml
At the end I'm posting part of my style code (on the request of one users here):
<style name="MyActionBarStyle" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:displayOptions">showHome</item>
<item name="android:background">#android:color/holo_blue_light</item>
<item name="android:backgroundStacked">#android:color/holo_blue_light</item>
<item name="android:backgroundSplit">#android:color/holo_blue_light</item>
</style>
Instead of using #android:color/holo_blue_light i should use probably something like #android:color/holo_main_color but the problem is it seems not to exist.

What are the themes/styles used for theming the overflow dropdown menu

I am trying to theme the overflow dropdown menu but I am having trouble finding the correct themes and styles for this part of the actionbar.
I am currently looking in the following files:
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/themes.xml
https://github.com/android/platform_frameworks_base/blob/master/core/res/res/values/styles.xml
Could anyone enlighten me please?
I managed to find what I wanted by creating a bogus holo theme here:
http://jgilfelt.github.com/android-actionbarstylegenerator/
Then I just looked at the example inside the zip file and updated my themes/styles files as so:
<item name="android:popupMenuStyle">#style/MyApp.Theme.PopupMenu</item>
<item name="android:dropDownListViewStyle">#style/MyApp.Theme.DropDownListView</item>
<style name="MyApp.Theme.PopupMenu" parent="#android:style/Widget.Holo.ListPopupWindow">
<item name="android:popupBackground">#drawable/theme_menu_popup_background</item>
</style>
<style name="MyApp.Theme.DropDownListView" parent="#android:style/Widget.Holo.ListView.DropDown">
<item name="android:listSelector">#drawable/theme_menu_popup_selector</item>
</style>
I would like to know how to totally overhaul everything but it seems I can only ever manage to drip feed my app with those essential theme/style specific bits because it takes soooo long to find the necessary styling syntax. If only there was an easier way.
Of course I have no idea how to position the ListPopupWindow or even change the color of the text but it's good enough for now.

android:style reference after SDK and ADT plugin update in mid 2011

I see a lot a similar questions R.java can't compile , No resource found that matches #android:style/ "just after SDK & ADT update" leading to existing projects can't compile
The R.java file cannot be compiled. I find out the errors come from referencing
<style name="Theme.Wallpaper" parent="android:style/Theme.Wallpaper" >
<item name="android:colorForeground">#fff</item>
</style>
What is happening is that some styles, like Theme.Wallpaper are not public. You should not extend from them anymore.
Some suggest to revert to platform_tools_r05
http://groups.google.com/group/android-developers/browse_thread/thread/550fce9670530d9b/9b2b2aa389dce367?show_docid=9b2b2aa389dce367&pli=1
If you want to do the correct way
read Xavier July 28
http://groups.google.com/group/android-developers/browse_thread/thread/550fce9670530d9b/9b2b2aa389dce367?show_docid=9b2b2aa389dce367&pli=1
If you wish to reuse a style that is private, you should copy the
content of that style into your own instead of extending it.
Ok so Where do I find the content of the (private) style ?
Seriously, after an update I don't have time to correct platform mistakes when the project code worked right.
<!-- Default theme for windows that want to have the user's selected
wallpaper appear behind them. -->
<style name="Theme.Wallpaper">
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:colorBackgroundCacheHint">#null</item>
<item name="android:windowShowWallpaper">true</item>
</style>
Looks like you want to use the above code from the Android source and create your own theme based it.

Categories

Resources