Is there a way to increase the fading edge or change top/bottom text alpha of number picker? I was able to extend NumberPicker class and change alpha of number picker wheel but once I start scrolling alpha gets applied to the center text as well. As you can see, I picked hour value and alpha got applied to all text. I want alpha to be only top and bottom number. Is there ANY way I can accomplish this. ?
private void updateTextAttributes(String fontName) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child instanceof EditText) {
try {
Field selectorWheelPaintField = NumberPicker.class.getDeclaredField("mSelectorWheelPaint");
selectorWheelPaintField.setAccessible(true);
Typeface typeface = Typeface.createFromAsset(getContext().getAssets(), "fonts/SFUIDisplay-" + fontName + ".ttf");
Paint wheelPaint = ((Paint) selectorWheelPaintField.get(this));
wheelPaint.setTextSize(mTextSize);
wheelPaint.setTypeface(typeface);
wheelPaint.setColor(mTextColor);
wheelPaint.setAlpha(50); //It does change alpha in the beginning but once I scroll then it also changes center text color
EditText editText = ((EditText) child);
editText.setTextColor(mTextColor);
editText.setTextSize(pixelsToSp(getContext(), mTextSize));
editText.setTypeface(typeface);
editText.setAlpha((float) 1.0);
invalidate();
break;
} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
e.printStackTrace();
}
}
}
}
Design
RESULT so far
EDIT: Ended up using this library