开发者

DropDown Spinner Alignment

I develop an Adroid application. So i want to customize programmatically the behavior of DropDown Spinner. I overwrite the getDropDownView method but i cannot find anything to change the dimension of DropDown and also the alignment of it. I only change the color of each line i开发者_如何学Pythonn DropDown like this

            View view = this.getView(position, convertView, parent);
        if (position % 2 == 0) {
            view.setBackgroundColor(Color.YELLOW);
        } else {
            view.setBackgroundColor(Color.GRAY);
        }

Can someone help me? Thanks


The alignment/horizontal offset of a spinner dropdown (which is a PopUp) is controlled by the value of the left padding of the spinner itself.

Therefore setting the left padding of a spinner to 0dp or between 0dp - 2dp should correct the left alignment, then setting a proper dropdown width with the .setDropDownWidth method of the spinner should correct the the right alignment.

To get a proper dropdown width, get the layout parameters of the spinner, and pass its width property to the .setDropDownWidth method of the spinner, you might have to make some little adjustment on this value to get the required alignment.


I wait for someone to help me. Not happened. So i found a workaround. I use a TextView and on click a ListView is displayed. So if someone find a better approach, please let me know

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜