Set spinner width to current item width

后端 未结 3 755
栀梦
栀梦 2020-12-16 04:32

By default the spinner width is set to fit the largest item in the dropdown but I want it to be the same width as the selected item.



        
3条回答
  •  执笔经年
    2020-12-16 05:07

      ViewGroup.LayoutParams spinnerLayoutParams = spinner.getLayoutParams();
        spinnerLayoutParams.width -= 1;
       spinner.setLayoutParams(spinnerLayoutParams);
    

    Do this is on item selected

提交回复
热议问题