how to change the dropdown height in spinner

后端 未结 11 1630
粉色の甜心
粉色の甜心 2021-02-05 11:20

i tried a lot to change the dropdown item height of spinner.. but i couldn\'t get a good solution.. plz help me guys..

here is a code loginactivityview.xml



        
11条回答
  •  孤街浪徒
    2021-02-05 11:53

    Maybe it can help..

    ArrayAdapter yourSpinnerAdapter = new ArrayAdapter(this,
                    R.layout.spinner_item, yourItem) {
    
            @Override
            public View getDropDownView(int position, View convertView,
                    ViewGroup parent) {
                convertView = super.getDropDownView(position, convertView,
                        parent);
    
                convertView.setVisibility(View.VISIBLE);
                ViewGroup.LayoutParams p = convertView.getLayoutParams();
                p.height = 100; // set the height
                convertView.setLayoutParams(p);
    
                return convertView;
            }
        };
    

提交回复
热议问题