フェード エッジを大きくしたり、ナンバー ピッカーの上部/下部のテキスト アルファを変更したりする方法はありますか? NumberPicker クラスを拡張し、番号ピッカー ホイールのアルファを変更することができましたが、スクロールを開始すると、中央のテキストにもアルファが適用されます。ご覧のとおり、時間の値を選択すると、すべてのテキストにアルファが適用されました。アルファは上下の数字だけにしたい。これを達成する方法はありますか。?
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();
}
}
}
}
デザイン
ここまでの結果
編集:このライブラリを使用して終了