-
Notifications
You must be signed in to change notification settings - Fork 353
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
Remove selected text color attribute #70
Conversation
- using android:textColor attribute you can specify a color resource or a hex value - if you specify a color state list, supported states are selected, focused and default - if you don't specify anything, it'll use the default_tab_text.xml color resource which behaves almost like the original sample (50% alpha instead of 150/255) for unselected tab text
❌ @jpardogo Opened this PR just so you can see what I mean, not specifically asking for a merge as it's API breaking again (on that note, can you clean As selected state is part of |
I will clean dev, match to master and start to do a proper git flow. I have been just lazy, but you are right. That makes completely sense. The are two reasons I didn´t do it this way: 1 - Different tab selectors for non selected tabs and selected tab (I think someone open an issue about that long ago ) 2 - I thought that once selected, the pressed state wasn´t gonna work for the selected tab text color (we have Like that pressed state color work in the already selected tab. <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#3e3" android:state_pressed="true" />
<item android:color="#FFFFFF" android:state_selected="true" />
<item android:color="#80FFFFFF" />
</selector> Like that it doesn´t: <selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="#FFFFFF" android:state_selected="true" />
<item android:color="#3e3" android:state_pressed="true" />
<item android:color="#80FFFFFF" />
</selector> Should we follow this approach and remove the possibility of different selectors (on non selected and selected tabs ) for the sake of the simplicity? |
Yep exactly, selectors work from top to bottom and pick the first match. I think it'd be best to do that, even if just to make the class simpler for For people doing funky things, they can provide their own tab layout - I
|
I agree people is driving me a bit crazy with his designs.... |
@@ -0,0 +1,5 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<item android:color="?android:textColorPrimary" android:state_selected="true" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't ?android:textColorPrimary
available in pre L releases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you're right, it's available. Doesn't look like it can be used as a color attribute though, weirdly - it doesn't resolve to the correct color (the resource ID gets parsed as the color, rather than resolving it). Using it as a drawable resource, like for a background, seems to work. So confused.
- Change order attr. Now the order is the same in attr.xml and java class constructor. - Better attr names, every attr related with tabs start with pstsTab - Android attr only use for container - No flipping the styles/appearance on selection/deselection tabs - Remove custom attire `pstsTextColorSelected ` and `pstsTextSelectedStyle ` - Callbacks for selection/deselection of tabs passing the tab view as parameter when custom tabs are use.
How can i add the selected tab in one color tab in Unselected tab in another Color. In Previous version you provided How can i change the Selected Tab Text color in this version. |
@yugeshdevaraja There's a note on the README explaining how to do this now. See issue #68 for more information about why it was changed.
A ColorStateList is a scary name for something that's not actually that bad - it just represents a list of colors which will be used depending on the state of the view. In this case, you'll need to provide the default and selected (or activated, correct me if I'm wrong @jpardogo) states. Create <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="@color/tab_text_selected" />
<item android:color="@color/tab_text_default" />
</selector> where <color name="tab_text_selected">#FFFFFF</color> Then you can assign this ColorStateList to the attribute: app:pstsTabTextColor="@color/tab_text" |
@ataulm Thanks 👍 |
@ataulm thanks thats a perfect solution for changing the selected tab colour |
This removes the custom attribute for tab text color selected, replacing it with the standard behaviour of
android:textColor
.Default case, with no
textColor
specified:Expected best case, with
textColor
specified with a custom color state list resource:Case with
textColor
specified with a color resource that's just a single color:Case with
textColor
specified with a hex value: