Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action background does not change #58

Open
ecunal opened this issue Jan 31, 2012 · 6 comments
Open

Action background does not change #58

ecunal opened this issue Jan 31, 2012 · 6 comments

Comments

@ecunal
Copy link

ecunal commented Jan 31, 2012

Hi, I was using a custom background for ActionBar but when I add a custom action to my ActionBar like

actionBar.addAction(new FinishTagging());

where FinishTagging implements Action, the background of the area where the icon of this activity is shown still looks like the default one (which is red) even if I explicitly change it after the adding the activity with the statement below:

actionBar.setBackgroundColor(getResources().getColor(R.color.titlebackgroundcolor));

I wonder is it a known issue or is it just my fault?

Thanks in advance.

@johannilsson
Copy link
Owner

There's limited support for changing the colors at runtime. My suggestion is that you instead change the colors using a theme.

@ecunal
Copy link
Author

ecunal commented Jan 31, 2012

I'm already changing the background color through xml file, I use the following style for ActionBar:

<style name="ActionBar"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> <item name="android:paddingLeft">5dp</item> <item name="android:paddingRight">5dp</item> <item name="android:layout_margin">0px</item> <item name="android:background">@color/titlebackgroundcolor</item> </style>

@johannilsson
Copy link
Owner

The problem is with your code where you change it from code. IIRC this is a limitation of Android, if you're using the mimic-api branch there's better support for theming that allows for separate themes on separate activities.

@ecunal
Copy link
Author

ecunal commented Jan 31, 2012

Alright, I was using master branch but I'll try the mimic-api one now. Thank you.

@johannilsson
Copy link
Owner

It's a bit more complex to setup but should do what you want. Take a look at the OtherActivity in the example project of how to make use of different themes for different activities.

@GuyWhoCodez
Copy link

hmmm this seems like a really silly issue which should be easily solved. I have been looking for the piece of code that sets it to that red background. I look in everything: styles, layouts, the class files..nothing...please change it to transparent if possible...thanks..

SOLVED::

"lol this is the second issue I am solving in nearly a few hours...

If you are getting a color behind your background (most likely red), then to change the color just do something like this in the addAction function in the ActionBar.java file.

mActionsView.setBackgroundColor(Color.TRANSPARENT);"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants