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

ActionMode appcompat-v7 (icon and text colors problem after setting up Calligraphy) #120

Closed
ferrannp opened this issue Jan 25, 2015 · 16 comments

Comments

@ferrannp
Copy link

Hello!

I have a Toolbar set up and I am also using an action mode with my color accent as a background.

Toolbar:

<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    app:contentInsetEnd="0dp"
    app:contentInsetLeft="72dp"
    app:contentInsetRight="0dp"
    app:contentInsetStart="72dp"
    android:elevation="4dp"
    app:navigationIcon="?attr/homeAsUpIndicator"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>

Theme:

<style name="AppBaseThemeMaterial" parent="Theme.AppCompat.Light">
...
    <item name="actionModeStyle">@style/AppBaseThemeMaterial.ActionMode</item>
</style>

<style name="AppBaseThemeMaterial.ActionMode" parent="@style/Widget.AppCompat.ActionMode">
    <item name="background">@color/colorAccent</item>
 </style>

What I used to see is:

screenshot_2015-01-26-00-48-07 2

But after setting up Calligraphy and using this into my main activity:

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

I see it in this way:

screenshot_2015-01-26-00-44-55 2

Text is black instead of white... And I only see the back arrow when pressing on it (it is the same color as the bar now!). Any ideas on why is this happening? Thank you!

@chrisjenx
Copy link
Owner

@ferrannp Shot in the dark here: I am going to assume this is related to:

 app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"

Can you add a but more code to complete the example, I think I know what this is but if I can replicate it that always helps!

Thanks,
Chris

@ferrannp
Copy link
Author

Hello! I'll try to write an example when I have time... yes basically I added those lines you quoted to do something like:

https://chris.banes.me/2014/10/17/appcompat-v21/

<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="@dimen/triple_height_toolbar"
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

I have a simple listview that uses CHOICE_MODE_MULTIPLE_MODAL. Unfortunately, there is no much information on how to style that text & icon of the Action Mode.

@chrisjenx
Copy link
Owner

@ferrannp yeah that is correct, this is to do with theme context, which isn't generated. I was suspicious this might happen but couldn't reproduce. So if you have a simple example that would be great :)

@castrojr913
Copy link

The same problem. I try to set the custom font and nothing: with all views is possible except for toolbar widget. The ideal way is to do it through styles.xml not by hard code, it's an ugly workaround. If i want to change the font for the app, so i have to change it on styles.xml and per each java class too, I think that's not the idea.

@chrisjenx
Copy link
Owner

@ferrannp try:

<android.support.v7.widget.Toolbar
    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:minHeight="@dimen/triple_height_toolbar"
    app:theme="@style/ThemeOverlay.AppCompat.Dark"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

Seem's defining app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" is wrong. Removing the ActionBar works fine.

@chrisjenx
Copy link
Owner

@castrojr913 the TextView's in the Toolbar get added programatically, If you define the titleStyle and subtitleStyle as per the old action bar impl, those will work. I am get to fully overhaul the deep linking into styles for Menus etc.. It's safe to say its a bit of a pain as they are not inflated traditionally.

@ferrannp
Copy link
Author

ferrannp commented Feb 3, 2015

Hi @chrisjenx, your solution didn't work for me. What I see changing Dark.ActionBar for Dark is:

screenshot_2015-02-03-23-41-24 2

So now I can see the arrow but still neither the title or the arrow are white.

@chrisjenx
Copy link
Owner

Very odd, as it works fine for me, I'll have to investigate more.

On Tue Feb 03 2015 at 10:48:18 PM Ferran Negre notifications@github.com
wrote:

Hi @chrisjenx https://github.com/chrisjenx, your solution didn't work
for me. What I see changing Dark.ActionBar for Dark is:

[image: screenshot_2015-02-03-23-41-24 2]
https://cloud.githubusercontent.com/assets/774577/6031378/0b2319c2-abff-11e4-92c6-4b4c0894888d.jpg

So now I can see the arrow but style neither the title or the arrow are
white.


Reply to this email directly or view it on GitHub
#120 (comment)
.

@chrisjenx
Copy link
Owner

@ferrannp are you able to pull out a broken sample into here?
I use this in a few apps now without issue, I can only guess its an Impli misunderstanding.

@ferrannp
Copy link
Author

A part from the code I posted, I set up the ActionMode using:

listView.setMultiChoiceModeListener(multiChoiceModeListener);

And start it using:

getListView().setItemChecked(position, !checkedItems.get(position));

(When there is some long click in some button inside the list).

Can I see some sample when this is working? Maybe will be faster :)

@chrisjenx
Copy link
Owner

Sorry have you tried setting the popup Theme to dark?

@chrisjenx
Copy link
Owner

@ferrannp I identified an issue tonight, I might of solved your issue. I'm about to push a snapshot.

@ferrannp
Copy link
Author

Hello! I tried version 2.0.2 and the issue is not happening anymore. Thank you! You're doing a great job here.

@roygwsidev
Copy link

Hello!
I getting issue on pre api 19 devices and using appcompat-v7:22.1.1.
Thanks

@chrisjenx
Copy link
Owner

@roygwsidev and are you using the latest version of Calligraphy?

@drakgoku
Copy link

drakgoku commented Jul 6, 2015

You can solve with this code :

toolbar.setTitleTextColor(0xFFFFFFFF);

I found here
http://stackoverflow.com/questions/26852108/how-do-you-set-the-title-color-for-the-new-toolbar

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

5 participants