小编Ale*_*lex的帖子

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

有没有办法增加数字选择器的衰落边缘或更改顶部/底部文本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(); …
Run Code Online (Sandbox Code Playgroud)

android android-custom-view android-layout android-number-picker

8
推荐指数
0
解决办法
1025
查看次数

Android - 减少EditText浮动标签填充/边距?

是否可以将这些浮动标签(电子邮件/密码)放在包装盒内.基本上减少了提示和实际输入之间的空间.

在此输入图像描述

我尝试填充顶部/底部.用于editText的边距顶部/底部.但他们都没有给出我想要的结果.


 <android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:id="@+id/emailWrapper"
    app:hintTextAppearance="@style/floatingLabel">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="54dp"
        android:paddingLeft="17dp"
        android:paddingRight="17dp"
        android:id="@+id/txtEmail"
        android:singleLine="true"
        android:inputType="textEmailAddress"
        android:hint="@string/emailPlaceholder"
        android:background="@drawable/btn_empty_stroke" />

</android.support.design.widget.TextInputLayout>

<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/floatingLabel"
    android:id="@+id/passwordWrapper"
    android:layout_below="@+id/emailWrapper">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="54dp"
        android:paddingLeft="17dp"
        android:paddingRight="17dp"
        android:singleLine="true"
        android:inputType="textPassword"
        android:id="@+id/txtPassword"
        android:paddingTop="0dp"
        android:text="HELLO"
        android:hint="@string/passwordPlaceholder"
        android:background="@drawable/btn_empty_stroke" />

</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout android-edittext android-textinputlayout

7
推荐指数
1
解决办法
1万
查看次数

Android - NumberPicker滚动/速度更快

如何使数字选择器滚动/速度更快?目前从00分钟到59分钟需要付出很多努力.我已经尝试了一些示例来自Android中Viewpager控制器的减速速度,并将其应用于数字选择器,但我没有看到任何差异.

在此输入图像描述

try {
        Field mScroller;
        mScroller = NumberPicker.class.getDeclaredField("mFlingScroller");
        mScroller.setAccessible(true);
        FixedSpeedScroller scroller = new FixedSpeedScroller(getContext(),null,true);

        // scroller.setFixedDuration(5000);
        // scrollBy(0,1500);

        Log.v("Scroller",""+mScroller); //getting the mFlingScroller field
        mScroller.set(this, scroller);

    } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
        e.printStackTrace();
    }

public class FixedSpeedScroller extends Scroller {

    private int mDuration = 10;

    public FixedSpeedScroller(Context context) {
        super(context);
    }

    public FixedSpeedScroller(Context context, Interpolator interpolator) {
        super(context, interpolator);
    }

    public FixedSpeedScroller(Context context, Interpolator interpolator, boolean flywheel) {
        super(context, interpolator, flywheel);
    }


    @Override
    public void startScroll(int …
Run Code Online (Sandbox Code Playgroud)

android android-scroll android-number-picker

7
推荐指数
0
解决办法
915
查看次数