How to customize actionbar navigate home button - android

<style name="MyActionBar.ActionBarStyle" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/button_style</item>
<item name="android:titleTextStyle">#style/MyTheme.ActionBar.TitleTextStyle</item>
</style>
The upper one is default , when i clicked it's background color seem like it. But i want it's background seems like as second.

Hi check this ActionBar Style Generator in Github ActionBar Style Generator . Hope it will help you. :)

Related

change the actionbar text color of an item

trying to change actionbar text color of this item in the action bar. here is the item
<item android:id="#+id/options_button"
android:title="#string/options"
android:showAsAction="ifRoom|withText"/>
and here is my styles.xml
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="MyCustomTheme" parent="#android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">#style/MyActionBarTheme</item>
<item name="android:background">#color/White</item>
<item name="android:textColor">#color/Red</item>
</style>
<style name="MyActionBarTheme" parent="#android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#color/White</item>
<item name="android:textColor">#color/Red</item>
</style>
</resources>
i saw other posts on here about this but after trying their solutions nothing worked for me? is it something to do with how i made the theme? All i really wanted was my action bar to be white, not display the title, and display a button that says options. I have all of that, but the options I want to be a red color im working with rather than black.
dont think people understand...
I know of the way to change the title (I dont have a title and i dont want one).I want to change the color of the item that is displaying itself in the actionbar...
I have faced the same issue, but I found a solution that doing well with any type of ActionBar (Native, Sherlock or Compat)
Actually you can use HTML code to set the title, and specify the text color. For example, to set the ActionBar text color to red, simply do this:
getActionBar()/* or getSupportActionBar() */.setTitle(Html.fromHtml("<font color=\"red\">" + getString(R.string.app_name) + "</font>"));
You can also use hex code of red color #FF0000 instead of the word red.
But, Setting a HTML string on the action bar doesn't work on the Material theme in SDK v21+.
If you want to change it you should set the primary text color in your style.xml as below.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="android:textColorPrimary">#color/actionbar-text-color</item>
May this helps you.

Customize touch feedback in Android ActionBar

I have my style defined as follows:
<style name="actionBarTheme" parent="android:style/Widget.Holo.Light.ActionBar">
<item name="android:background">#drawable/button_style</item>
<item name="android:titleTextStyle">#style/actionBarTitleText</item>
</style>
And the actionBar is actually of the color defined in button_style (correctly working in other parts of the code). The problem is that the items are not working correctly (the background color is too light).
Any idea on how to solve this? Thanks
EDIT:
In the picture there is the touch-feedback that I have now. The button_style has another touch effect (a darker one) since this is almost invisible.
You can have this affect with actionButtonStyle
<style name="appTheme">
<item name="android:actionBarStyle">#style/actionBarTheme</item>
<item name="android:actionButtonStyle">#style/actionButtonTheme</item>
</style>
and then place your button style as the background of that.
<style name="actionButtonTheme">
<item name="android:background">#drawable/button_style</item>
</style>
You will still need to set the background of your action bar but this only needs to be a colour or drawable image as that is all that will actually be used.

Actionbar Compat change title textColor

I am trying to modify the text color of the title of the ActionBarSupport. I have used ActionBarStyleGenererator to create a theme with the correct colors and it works well.
While using the light theme, I would like to change the color of the heading to white (in the genererator I cannot set the text color(. For a number of reasons I cannot use the dark actionbar theme. I am so close, just have to get the title to white ;-)
What I am doing wrong here?
<style name="ActionBar.Transparent.MyApp" parent="#style/Widget.AppCompat.Light.ActionBar">
<item name="background">#drawable/ab_transparent_myapp</item>
<item name="progressBarStyle">#style/ProgressBar.MyApp</item>
<item name="titleTextStyle">#style/MyApp.TitleTextStyle</item>
</style>
<style name="MyApp.TitleTextStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#ffffff</item>
</style>
The below code worked for me. I hope it will help you tooo.
<style name="AppTheme" parent="AppBaseTheme">
<item name="actionBarStyle">#style/ActionBarCompat</item>
</style>
<style name="ActionBarCompat" parent="#style/Widget.AppCompat.Base.ActionBar">
<item name="titleTextStyle">#style/titleStyle</item>
</style>
<style name="titleStyle" parent="#style/TextAppearance.AppCompat.Widget.Base.ActionBar.Title">
<item name="android:textColor">#android:color/white</item>
</style>
Embarrassing. I was not paying attention to the values-v14/-folder (which overrides the vales/) ActionBarStyleGenererator created. Using the android-prefix on the styles in values-v14 it worked:
<item name="android:titleTextStyle">#style/titleTextStyle</item>
Found at Overflow styling
I've been trying to keep the ActionBar title text color through orientation changes without much luck until I got a clue from the above site. I applied the Spannable to to the title. Here's what i do when setting up my ActionBar:
Spannable actionBarTitle = new SpannableString("Action Bar Title");
actionBarTitle.setSpan(
new ForegroundColorSpan(Color.WHITE),
0,
actionBarTitle.length(),
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mActionBar.setTitle(actionBarTitle);
This needs to be executed on orientation change. I call it from onCreate()...don't know if it works in onConfigurationChange().
#TNR is correct, however you should double check if your layout xml file has not overriden the android:theme attribute with a different style.
This usually happens if you have generated layout files

Android ContextMenu how set TextColor and bg color?

I need to change the color of the text in a ContextMenu. I try to use #style, but doesn't work. I cheked the post: Setting Application theme textColor to white causes Context Menu item text to be white (invisible), cause de doubt is simillar, but no dont works too. Someone can help me or tell me that is not possible change the color?
Tks.
<style name= "Theme.Blundell.Light" parent="#android:style/Theme.NoTitleBar">
<item name="android:windowBackground">#drawable/background_light</item>
<item name="android:textViewStyle">#style/Widget.TextView.Black</item>
</style>
<style name="Widget.TextView.Black" parent="#android:style/Widget.TextView">
<item name="android:textColor">#000000</item>
</style>

Action bar with text in the middle of it that is clickable

I am trying to do in my app that i will have a clickable text in the middle of the actionbar like the whatsapp app have ,
In this picture you will see in the actionbar it got details of the person and its clickable , that is the exactly thing i am looking for
I saw that i can add subtitles and ofcourse the main title of the actionbar but i didnt seem to find a good result for that exact thing
Thanks heads up :)
Add TextView as CustomView that will mimic the plain title and at the same time clickable, instead putting it with setTitle(). Add click listener to the TextView before you supply it to the ActionBar. Don't forget to stretch to the size of the ActionBar.
Hope this idea helps.
Edit:
To get the same appearance in terms of size of text of the title and subtitle look at styles.xml
<style name="TextAppearance.Widget.ActionBar.Title"
parent="#android:style/TextAppearance.Medium">
</style>
<style name="TextAppearance.Widget.ActionBar.Subtitle"
parent="#android:style/TextAppearance.Small">
</style>
<style name="TextAppearance.Medium">
<item name="android:textSize">18sp</item>
</style>
<style name="TextAppearance.Small">
<item name="android:textSize">14sp</item>
<item name="android:textColor">?textColorSecondary</item>
</style>
use this way:
ActionBar action = getSupportActionBar();
action.setHomeButtonEnabled(true);
action.setDisplayShowTitleEnabled(true);
action.setTitle("Title");
action.setSubtitle("Sub title");
action.setIcon(getResources().getDrawable(R.drawable.ic_launcher));
for < 11 Android API use actionbarsherlock
or you can also use custom layout for actionbar and actionbar item click.
https://stackoverflow.com/a/7981633/1168654

Categories

Resources