Change text color of selected item in spinner

后端 未结 14 1545
情深已故
情深已故 2020-11-29 06:17

How can I change the font color of the selected item in a spinner?

I am able to change the background color of the selected item, the color of the dropdown item etc,

14条回答
  •  南笙
    南笙 (楼主)
    2020-11-29 06:52

    I know this is old question, but I had big problem on changing color of selected item in spinner in TabLayout and this really worked for me:

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

提交回复
热议问题