更改NumberPicker渐变边缘值或更改顶部/底部文本的alpha

Ale*_*lex 8 android android-custom-view android-layout android-number-picker

有没有办法增加数字选择器的衰落边缘或更改顶部/底部文本alpha?我能够扩展NumberPicker类并更改数字选择器轮的alpha但是一旦我开始滚动alpha也会应用到中心文本.正如你所看到的,我选择了小时值并且alpha应用于所有文本.我希望alpha只是顶部和底部的数字.我有什么方法可以做到这一点.?

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();
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

设计

在此输入图像描述

结果到目前为止

在此输入图像描述

编辑:结束使用此