Change action bar overflow icon - android

I have applied the following code in values-v11 folder
styles.xml
<style name="actionBarTheme" parent="android:Theme.Holo.Light">
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow" parent="#android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:src">#drawable/action_item_btn</item>
</style>
But it not changing the overflow icon, all the other items in this theme is working fine but not this one, am i missing anything ?

i want to apply these styles above 4.0 version
But you have the styles in values-v11
Also note
parent="android:Theme.Holo.Light" // in your code
to
parent="#android:style/Theme.Holo" // mine
It should be in values-v14
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo">
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
<style name="MyActionButtonOverflow" parent="#android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:src">#drawable/ic_launcher</item>
</style>
</resources>
Snap
Forget how the ui look's this is for testing. But you see the launcher icon as the overflow menu icon.
Edit:
This is my test sample
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionBarDivider">#color/red</item>
<item name="android:actionOverflowButtonStyle">#style/MyActionButtonOverflow</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
<item name="android:textStyle">bold</item>
</style>
<style name="MyActionButtonOverflow" parent="#android:style/Widget.Holo.Light.ActionButton.Overflow">
<item name="android:src">#drawable/launcher</item>
</style>
<style name="ActionButton" parent="#android:style/Widget.Holo.Light.ActionButton">
</style>
</resources>
Colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
Snap

i think you should do the following :
<style name="MyCustomTheme" parent="style/Theme.Holo">
<item name="android:actionOverflowButtonStyle">#style/MyCustomTheme.OverFlow</item>
</style>
<style name="MyCustomTheme.OverFlow">
<item name="android:src">#drawable/my_overflow_image</item>
</style>

You can set it programmatically in Java like this:
toolbar.setOverflowIcon(getResources().getDrawable(R.drawable.your_icon, null));

Related

Error:The prefix "xmlns" cannot be bound to any namespace explicitly to android studio

I am getting below error while importing the eclipse code to Android studio.
I am not getting why this is happening
I have already tried for possible solutions by checking XMLNS and other custom tags.
Remove all xmlns:android="http://schemas.android.com/apk/res/android" in your main\res\values\style.xml file from style tag.
Here is is the sample code:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style xmlns:android="http://schemas.android.com/apk/res/android" name="RadioButton" parent="#android:style/Widget.CompoundButton">
<item name="android:button">#null</item>
<item name="android:padding">5dp</item>
</style>
<style xmlns:android="http://schemas.android.com/apk/res/android" name="EditText" parent="#android:style/Widget.EditText">
<item name="android:textSize">15sp</item>
</style>
</resources>
It should be like this:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="AppBaseTheme" parent="android:Theme.Light">
</style>
<style name="AppTheme" parent="AppBaseTheme">
</style>
<style name="RadioButton" parent="#android:style/Widget.CompoundButton">
<item name="android:button">#null</item>
<item name="android:padding">5dp</item>
</style>
<style name="EditText" parent="#android:style/Widget.EditText">
<item name="android:textSize">15sp</item>
</style>
</resources>

AppCompat, trying to style tabbar in version 7.21

I am trying to style the TabBar using the following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="MyTheme" parent="MyTheme.Base"/>
<style name="MyTheme.Base" parent="Theme.AppCompat">
<item name="colorPrimary">#color/palette_1</item>
<item name="colorPrimaryDark">#color/palette_5</item>
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">true</item>
<item name="android:windowBackground">#color/palette_1</item>
<item name="android:actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarStyle">#style/MyTheme.ActionBar</item>
<item name="actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
<item name="android:actionBarTabStyle">#style/MyTheme.ActionBarTabBar</item>
</style>
<style name="MyTheme.ActionBar" parent="#style/Widget.AppCompat.Light.ActionBar.Solid.Inverse">
<item name="background">#color/palette_5</item>
<item name="backgroundStacked">#color/palette_5</item>
<item name="backgroundSplit">#color/palette_5</item>
</style>
<style name="MyTheme.ActionBarTabBar" parent="#style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">#color/palette_5</item>
</style>
<style name="MyTheme.NoTitleBar" parent="MyTheme">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
</style>
</resources>
Whewre palette_1 is green and palette_5 is blue for example.
The actionBar is blue but the tabbar stays the color that i define in android:windowBackground, which is green.
This is the code i came up with after searching numerous topics. But yet it seems to be conflicting somewhere.

Changing Action Bar attributes with AppCompat android

I am trying to get a red action bar with white text and I would also like to customize the font of the text, nothing I have tried works, the answer given here Change Background color of the action bar using AppCompat doesn't work. Here is my xml
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="android:titleTextStyle">#style/ActionBarTitleText</item>
<item name="android:background">#color/red</item>
<item name="background">#color/red</item>
</style>
<style name="ActionBarTitleText">
<item name="android:textColor">#android:color/white</item>
</style>
It seems like everything in here is being ignored, the action bar is black, along with basically everything else on screen, which I really don't want.
make two folders under res (values and values-v14) if they are not there.
add this code in res (values) folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="#style/Theme.AppCompat.Light">
<item name="actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#color/red</item>
<item name="titleTextStyle">#style/MyTextColor</item>
</style>
<style name="MyTextColor"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
then this code in res (values-v14) add this code
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="Theme.Styled" parent="#style/Theme.AppCompat.Light">
<item name="android:actionBarStyle">#style/Widget.Styled.ActionBar</item>
</style>
<style name="Widget.Styled.ActionBar"
parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="android:background">#color/red</item>
<item name="android:titleTextStyle">#style/MyTextColor</item>
</style>
<style name="MyTextColor"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
In your manifest set theme to Theme.Styled

Android app label color

I don't want to create any custom layout for app label, just want to change it's color to white (now it's black). How could I do that?
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:background">#drawable/bg_blue_solid_onclick</item>
//////CHANGE label color
</style>
</resources>
styles.xml
<style name="MyTheme" parent="#android:style/Theme.Holo">
<item name="android:actionBarStyle">#style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#FF9D21</item>
<item name="android:titleTextStyle">#style/MyActionBarTitleText</item>
</style>
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
</style>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red">#FF0000</color>
</resources>
For more info
https://developer.android.com/training/basics/actionbar/styling.html#CustomText
Snap
Edit : For making it bold
<style name="MyActionBarTitleText"
parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/red</item>
<item name="android:textStyle">bold</item>
</style>
None of the previous answers worked for me, so I'm showing the one that worked in my case.
<style name="AppThemeCustom" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/primary</item>
<item name="colorPrimaryDark">#android:color/black</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="actionBarStyle">#style/MyActionBar</item>
<item name="android:windowBackground">#android:color/white</item>
</style>
<style name="MyActionBar" parent="#style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">#style/MyTitleTextStyle</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">#style/MyTitleTextStyle</item>
</style>
<style name="MyTitleTextStyle"
parent="#style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">#android:color/black</item>
</style>
I wish if you find yourself in my situation this solution save your day. LOL
You need to style the android:titleTextStyle in your ActionBar.
<style name="MyActionBar" parent="#android:style/Widget.Holo.ActionBar">
<item name="android:titleTextStyle">#style/MyTextTitle</item>
</style>
<style name="MyTextTitle" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#color/white</item>
</style>
You can see this in Android Documentation: Customize the Text Color in ActionBar
Hope this helps.
in styles.xml
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
in toolbar
android:theme="#style/AppTheme.AppBarOverlay"

Styling Action Bar Text Color - Android

<style name="Theme.RateItTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
</style>
<style name="MyActionBar.Text" parent="#android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="android:textColor">#ECECEC</item>
</style>
I have been able to change the background, but not the text color. Or the overflow menu "three dots". My code is above.
You need to move your titleTextStyle attribute into your MyActionBar style. Do you understand why it's supposed to be placed there rather than where you had it originally?
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
As far as changing the Overflow icon, I think that's what mean when you say "three dots", I've already written a post about that here.
Try this
<?xml version="1.0" encoding="utf-8"?>
<!-- For honeycomb and up -->
<resources>
<style name="Theme.RateItTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBar</item>
<item name="android:actionMenuTextColor">#color/actionBarText</item>
</style>
<style name="MyActionBar" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#2E495E</item>
<item name="android:titleTextStyle">#style/MyActionBar.Text</item>
</style>
<style name="MyActionBar.Text" parent="#android:style/TextAppearance">
<item name="android:textColor">#ECECEC</item>
</style>
</resources>

Categories

Resources