blazsolar / HorizontalPicker

Android widget allowing user to select one item from set of them by swiping left and right.
http://blaz.solar/HorizontalPicker
Apache License 2.0
227 stars 81 forks source link

Maybe make it easier to style selected item (i.e. color and size) #29

Open isuPatches opened 9 years ago

isuPatches commented 9 years ago

it'd be cool to have methods to set the color and size of the selected item

ArcherN9 commented 8 years ago

Was looking for something with that capability. It would be really good to have.

blazsolar commented 8 years ago

Color can already be set through textColor parameter. Selected state is for the middle item.

Test size for selected item is a bit trickier since the view would have to calculate text size on every frame. That could cause some performance issue.

ziad-halabi9 commented 8 years ago

Can you please elaborate on how we can achieve that? Thank you!

Mandeep221 commented 8 years ago

Hello fellow coders! If anyone has implemented this enhancement, Please help me. Thanks!

jpage4500 commented 6 years ago

Can you please elaborate on how we can achieve that?

this works.. create an xml file like this one: number_selector.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:color="@color/colorPrimary" android:state_pressed="true"/>
    <item android:color="@color/colorPrimary" android:state_selected="true"/>
    <item android:color="@color/gray_1E1E1E"/>
</selector>

and then use it:

            <com.wefika.horizontalpicker.HorizontalPicker
...
                android:textColor="@drawable/number_selector"

btw - I also wish the text size and/or style could be changed for the selected item.. not sure how hard that'd be to implement