11package com .h3c .shengshiqu .widget ;
22
33import android .content .Context ;
4- import android .graphics .Color ;
54import android .graphics .drawable .ColorDrawable ;
65import android .util .AttributeSet ;
76import android .view .View ;
@@ -52,7 +51,7 @@ public void addView(View child, android.view.ViewGroup.LayoutParams params) {
5251 public void updateView (View view ) {
5352 if (view instanceof EditText ) {
5453 //这里修改字体的属性
55- ((EditText ) view ).setTextColor (Color .parseColor ("#464A4C" ));
54+ // ((EditText) view).setTextColor(Color.parseColor("#464A4C"));
5655 ((EditText ) view ).setTextSize (12 );
5756 }
5857 }
@@ -61,18 +60,26 @@ public void updateView(View view) {
6160 public void setDisplayedValues (String [] displayedValues ) {
6261 super .setDisplayedValues (displayedValues );
6362
64- Field [] pickerFields = NumberPicker .class .getDeclaredFields ();
65- for (Field pf : pickerFields ) {
66- if (pf .getName ().equals ("mSelectionDivider" )) {
67- pf .setAccessible (true );
68- try {
69- //设置分割线的颜色值
70- pf .set (this , new ColorDrawable (Color .parseColor ("#F8A441" )));
71- } catch (Exception e ) {
72- e .printStackTrace ();
63+ int customDividerColor = customDividerColor ();
64+ if (customDividerColor != 0 ) {
65+ Field [] pickerFields = NumberPicker .class .getDeclaredFields ();
66+ for (Field pf : pickerFields ) {
67+ if (pf .getName ().equals ("mSelectionDivider" )) {
68+ pf .setAccessible (true );
69+ try {
70+ //设置分割线的颜色值
71+ pf .set (this , new ColorDrawable (customDividerColor ));
72+ } catch (Exception e ) {
73+ e .printStackTrace ();
74+ }
75+ break ;
7376 }
74- break ;
7577 }
7678 }
7779 }
80+
81+ // 自定义分割线的颜色
82+ public int customDividerColor () {
83+ return 0 ;
84+ }
7885}
0 commit comments