Android HoneyComb DatePicker Text Color

后端 未结 5 1924
小鲜肉
小鲜肉 2020-12-03 14:25

I\'m searching for a possibilitie to adjust the text color of the datepicker widget in an android honeycomb app. I knew that the widget inherent the global text-color which

5条回答
  •  既然无缘
    2020-12-03 14:55

    I had a similar issue, although I was looking to change the text size, but that's a minor detail. I used the same process to pick apart the View hierarchy and change the font size. However, once a month (or day or year) was changed, the font changed back to the original value. Great for viewing, bad for editing. I took the next step and added a change listener. Now when the value gets changed, it pops back to the preferred font size:

    public void setFontSize(final int size) {
    
        LinearLayout l = (LinearLayout) mPicker.getChildAt(0);
        if (l != null) {
            l = (LinearLayout) l.getChildAt(0);
            if (l != null) {
                for (int i = 0; i < 3; i++) {
                    NumberPicker np = (NumberPicker) l.getChildAt(i);
                    for (int x = 0; x < np.getChildCount(); x++) {
                        View view = np.getChildAt(x);
                        if ((view != null) && (view instanceof TextView)) {
                            final TextView tv = (TextView) view;
                            tv.setTextSize(size);
                            tv.setOnEditorActionListener(new OnEditorActionListener() {
    
                                public boolean onEditorAction(TextView v,
                                        int actionId, KeyEvent event) {
                                    tv.setTextSize(size);
                                    return false;
                                }
                            });
                        }
                    }
                }
            }
        }
    
    }
    

提交回复
热议问题