zoukankan      html  css  js  c++  java
  • NumberPicker设置宽度,设置文字颜色

    修改宽度

    wheel = (NumberPicker) findViewById(R.id.info_wheel_province);
    wheel.setLayoutParams(new LinearLayout.LayoutParams(deviceSize.x >> 1, LinearLayout.LayoutParams.WRAP_CONTENT));

    修改文字颜色

    public static boolean setNumberPickerTextColor(NumberPicker numberPicker, int color) {
            boolean result = false;
            final int count = numberPicker.getChildCount();
            for (int i = 0; i < count; i++) {
                View child = numberPicker.getChildAt(i);
                if (child instanceof EditText) {
                    try {
                        Field selectorWheelPaintField = numberPicker.getClass()
                                .getDeclaredField("mSelectorWheelPaint");
                        selectorWheelPaintField.setAccessible(true);
                        ((Paint) selectorWheelPaintField.get(numberPicker)).setColor(color);
                        ((EditText) child).setTextColor(color);
                        numberPicker.invalidate();
                        result = true;
                    } catch (NoSuchFieldException e) {
                        e.printStackTrace();
                    } catch (IllegalAccessException e) {
                        e.printStackTrace();
                    } catch (IllegalArgumentException e) {
                        e.printStackTrace();
                    }
                }
            }
            return result;
        }

    效果

  • 相关阅读:
    python_6
    python_day4
    python_day3
    python_day2
    python
    python入门
    jQuery之前端国际化jQuery.i18n.properties
    转载!网页中插入百度地图
    jQuery.validate 中文API
    Web移动端Fixed布局的解决方案
  • 原文地址:https://www.cnblogs.com/xirtam/p/4696266.html
Copyright © 2011-2022 走看看