Change the text color of NumberPicker
This code should solve your problem. The problem you are experiencing is because during the construction of NumberPicker it captures the EditText textColor and assigns to to a paint so it can draw the numbers above and below the edit text with the same color.
import java.lang.reflect.Field;
public static void setNumberPickerTextColor(NumberPicker numberPicker, int color)
{
try{
Field selectorWheelPaintField = numberPicker.getClass()
.getDeclaredField("mSelectorWheelPaint");
selectorWheelPaintField.setAccessible(true);
((Paint)selectorWheelPaintField.get(numberPicker)).setColor(color);
}
catch(NoSuchFieldException e){
Log.w("setNumberPickerTextColor", e);
}
catch(IllegalAccessException e){
Log.w("setNumberPickerTextColor", e);
}
catch(IllegalArgumentException e){
Log.w("setNumberPickerTextColor", e);
}
final int count = numberPicker.getChildCount();
for(int i = 0; i < count; i++){
View child = numberPicker.getChildAt(i);
if(child instanceof EditText)
((EditText)child).setTextColor(color);
}
numberPicker.invalidate();
}
android Number picker text colour
As per our discussion in comments, the code here, requires a parameter from the Color
class. Pass a color using this class.
how to select text color of numberpicker in flutter
There are two TextStyle
textStyle
: others than selected text(except middle one)selectedTextStyle
: selected/middle textStyle
NumberPicker(
textStyle: TextStyle(color: Colors.pink),
selectedTextStyle: TextStyle(color: Colors.amber),
value: _currentValue,
minValue: 0,
maxValue: 100,
onChanged: (value) => setState(() => _currentValue = value),
),
Related Topics
Android App Crashes When Launched in Debug Mode
Failed Binder Transaction When Putting an Bitmap Dynamically in a Widget
How to Use Setarguments() and Getarguments() Methods in Fragments
Android - How to Pass Hashmap<String,String> Between Activities
Reading SQLite File from Asset Folder
Android Action Bar Not Showing Overflow
Show Icon in Actionbar/Toolbar with Appcompat-V7 21
How to Make My Layout Scroll Both Horizontally and Vertically
Activenetworkinfo.Type Is Deprecated in API Level 28
How to Turn Speaker On/Off Programmatically in Android 4.0
Find Out If Listview Is Scrolled to the Bottom
How to Get My Android Device Country Code Without Using Gps
How to Open an Android Studio Project in Eclipse
Parse JSON Array Without Key in Android
How to Use Adb to Send Touch Events to Device Using Sendevent Command
Error:Failed to Open Zip File. Gradle's Dependency Cache May Be Corrupt
Retaining Position in Listview After Calling Notifydatasetchanged