About the spinner's height in Android
How c开发者_JS百科an I set the height of the spinner? I mean the dropdown items's height.
For I found in SDK12 my spinner will show a long long item list to show the dropdown items. But it shows to long , how can i set the height?You can call setDropDownViewResource method and pass corresponding layout, on ArrayAdapter.
In this example im setting simple_spinner_dropdown_item resource which is higher than regular and has a radiobutton. I think you can pass your custom layout to.
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
And in case you are making custom layout, you'll have to declare TextView as root element in order to adapter fill it with text.
Maybe it could 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;
}
};
精彩评论