I am making a daydream application and I want the settings activity to follow the same interface as the standard settings. For right now I want to make the app use the Holo theme but have a dark action bar like you can get with the Holo.Light.DarkActionBar theme. I've googled around and have not found anything similar, and I tried looking through the android source code to find out how they do it for the Settings page, but it is too big for me to handle and I cannot find the styling system.
I've got my styles set up but I cannot find the correct value to use for actionbar style. I do not have interest in adding more libraries like actionbar sherlock.
NOTE: Dark Action Bar =/= Holo actionbar.
My app only works with 4.2 and up so the Holo.Light.DarkActionBar theme should exist.
For reference, I want my app to have this theme:
The settings app uses the Widget.Holo.ActionBar.Solid for its actionBarStyle. As in:
<style name="Your.Theme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#android:style/Widget.Holo.ActionBar.Solid</item>
</style>
Related
I started a new empty activity. I am in the start of the project. By default my theme is set to AppTheme. I dont want the title bar on my theme. I changed the theme to NoTitleBar and lot of other themes. I am getting this error.
Missing styles. Is the correct theme chosen for this layout? Use the Theme combo box above the layout to choose a different layout, or fix the theme style references. Failed to find '?attr/textEditSuggestionItemLayout' in current theme. (9 similar errors not shown) Tip: Try to refresh the layout.
I tried lot of other themes and I am getting errors like this. Is there a way I could select a theme where I dont want to have a title bar on my app?
If not, how can I change the color of my title bar and add a logo?
chose holo light them from them box above the layout
You mean, project name?
You can use NoActionBar if you dont want this code in your styles
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
</style>
I had my app looking pretty nice using the new Lollipop tools. I decided backwards compatibility is important, so I switched all my Fragments,actionBar imports to the support library. Now (understandably) I can't use my lollipop theme.
Is there a way to use different action bars for different themes? I tried to cast the support ActionBar to a new one but it doesn't seem this is allowed.
My problem lies with the following (from v21 docs)
All of your Activities must extend from ActionBarActivity, which
extends from FragmentActivity from the v4 support library, so you can
continue to use fragments. All of your themes (that want an Action
Bar/Toolbar) must inherit from Theme.AppCompat. There are variants
available, including Light and NoActionBar. When inflating anything to
be displayed on the action bar (such as a SpinnerAdapter for list
navigation in the toolbar), make sure you use the action bar’s themed
context, retrieved via getSupportActionBar().getThemedContext(). You
must use the static methods in MenuItemCompat for any action-related
calls on a MenuItem.
so by calling getsupportActionBar I can't use my Holo theme:
<resources>
<!-- Base application theme. -->
<style name="appTheme" parent="android:Theme.Holo.Light.DarkActionBar">
</style>
<style name="MyActionBar"
parent="android:Theme.Holo.Light.DarkActionBar">
<item name="android:background">#color/blue_semi_transparent</item>
</style>
</resources>
Also for some reason the action bar loses the button that was on it and it goes into the dropdown menu and the app icon no longer appears in the action bar.
I really am no expert on this stuff having only started developing on lollipop so would really appreciate advice.
AppCompat (i.e., ActionBarActivity) uses the Material color palette which defines default coloring throughout your app. In your case, you need to use colorPrimary for your action bar color:
<style name="appTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">#color/blue_semi_transparent</item>
</style>
Note that you should also provide a colorPrimaryDark (a darker version of the same color) for coloring the status bar.
Per the partially outdated Action Bar training, AppCompat also uses app namespaced attributes (as things like showAsAction didn't exist before API 11) for your menu items:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" >
<item android:id="#+id/action_search"
android:icon="#drawable/ic_action_search"
android:title="#string/action_search"
app:showAsAction="ifRoom" />
...
</menu>
Per the Toolbar documentation (which is default behavior on Material themes and in AppCompat):
In modern Android UIs developers should lean more on a visually distinct color scheme for toolbars than on their application icon. The use of application icon plus title as a standard layout is discouraged on API 21 devices and newer.
Therefore as you noted the app icon not appearing on the Action Bar is expected behavior.
So I created my app to have tabs on the action bar which direct to three fragment windows. I decided to change the theme of the app to "#android:style/Theme.Holo.Light.NoActionBar.Fullscreen" and suddenely my app started crashing with a nullpointer exception. After sometime I realized that the theme change, which disabled the action bar might have caused this.
Is there a way to implement tabbed layout without an action bar? A custom action bar? I badly want to use that theme. OR is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
Thank you!
Is there a way to implement tabbed layout without an action bar?
Use ViewPager and any one of several tabbed indicators, such as PagerTabStrip, the TabPageIndicator from the ViewPagerIndicator library, PagerSlidingTabStrip, etc.
Or, use FragmentTabHost.
is there a way to customize the action bar: change the color or add custom icons and search function to make it more visually appealing?
You are responsible for your own icons, so if you do not like your icons, talk to yourself about having yourself come up with better ones.
You can change the color of the action bar via a custom theme, such as one you might set up with Jeff Gilfelt's Action Bar Style Generator. Or, switch to using the appcompat-v7 edition of the action bar (with ActionBarActivity) and you can use a simpler custom theme where you just set some tint values.
as you have not provided code here i think you are using API 21 or less.. so you should change theme of your android application.
change styles.xml file as follows
<resources>
<!-- Base application theme. -->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
</style>
I'n my theme I'm trying to restyle the easy share action on the action bar to remove the border around the icons. I found
<item name="activityChooserViewStyle">#android:style/Widget.Holo.Light.ActivityChooserView</item>
In the holo theme but I'm unable to use it in my theme; in fact, there's no activityChooserViewStyle in R.attr but only in R.attr in ActionbarCompat. So the item is present in the holo them but it's not exposed in R.attrs.
Is there a solution to this? Should I use ActionbarCompat even if I'm only supporting api level 14+?
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...