How to change spinner text size and text color?

后端 未结 24 2163
囚心锁ツ
囚心锁ツ 2020-11-22 11:35

In my Android application, I am using spinner, and I have loaded data from the SQLite database into the spinner, and it\'s working properly. Here is the code for that.

24条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 12:37

    If you want the text color to change in the selected item only, then this can be a possible workaround. It worked for me and should work for you as well.

    spinner.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    ((TextView) spinner.getSelectedView()).setTextColor(Color.WHITE);
                }
            });
    

提交回复
热议问题