android - NumberPicker textColour -
i have listview
containing textview
, numberpicker
each row. whenever start activity, numbers of numberpicker
white (the same color background).
i tried applying style suggested here, here, , here ; no avail.
any other suggestions?
-
numberpicker.xml
<numberpicker android:id="@+id/npmaterialamount" android:layout_alignparentright="true" android:layout_width="wrap_content" android:layout_height="75dp" style="@style/npcolour"/>
-
tried style 1:
<style name = "npcolour" > <item name = "android:textcolor">#000000</item> </style>
-
tried style 2:
<style name = "npcolour" parent ="@android:style/theme.holo.light"> </style>
-
... , list goes on...
i know question old. founded answer here: change text color of numberpicker
copy:
this code should solve problem. problem experiencing because during construction of numberpicker captures edittext textcolor , assigns to paint can draw numbers above , below edit text same color.
import java.lang.reflect.field; public static boolean setnumberpickertextcolor(numberpicker numberpicker, int color) { final int count = numberpicker.getchildcount(); for(int = 0; < count; i++){ view child = numberpicker.getchildat(i); if(child instanceof edittext){ try{ field selectorwheelpaintfield = numberpicker.getclass() .getdeclaredfield("mselectorwheelpaint"); selectorwheelpaintfield.setaccessible(true); ((paint)selectorwheelpaintfield.get(numberpicker)).setcolor(color); ((edittext)child).settextcolor(color); numberpicker.invalidate(); return true; } catch(nosuchfieldexception e){ log.w("setnumberpickertextcolor", e); } catch(illegalaccessexception e){ log.w("setnumberpickertextcolor", e); } catch(illegalargumentexception e){ log.w("setnumberpickertextcolor", e); } } } return false; }
Comments
Post a Comment