如何管理Android的微调项目的高度? [英] How can I manage the height of android spinner items?

查看:191
本文介绍了如何管理Android的微调项目的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个年代由一个字符串列表,使用ArrayAdapter填充一个Android微调和它的运作却因显示微调,我遇到了一个显示高度的问题的列表项的方式很好,

I have an android spinner that's populated by a list of strings using an ArrayAdapter and it operates fine, however because of the way the spinner is displayed I'm running into a display height problem with the list items.

乍一看,这似乎是一个ArrayAdapter可以使用单个布局显示选项从而导致我遇到的问题。当在所说的纺丝器显示当前项的纺丝器垫(当用户未从列表中选择一个新项目)的文本,以使离心器是用于点击合理的大小。然而,当用户点击它,会弹出列表中选择一个新的项目,列表项presented也一路小高度明智的。如果我用一个项目的布局,$在一个合理的高度p $ psents列表项,那么微调本身变得如愿巨大的,由于它自身的列表项的填充。

At first glance it would seem that the ArrayAdapter can use a single layout for displaying options which leads to the problem I'm having. When displaying the current item in the spinner (when the user is not selecting a new item from the list) the spinner pads the text so that the spinner is a reasonable size for clicking on. However when the user taps on it and brings up the list to select a new item, the list items presented are way to small height-wise. If I use an item layout that presents the list items at a reasonable height, then the spinner itself becomes exorbitantly huge due to it's own padding of the list item.

我如何能管理这两个项目显示模式的高度,使他们有效地显示具有相同的高度值,而不是微调的高度比列表项显示高度?

Any ideas on how I can manage the height of these two item display modes so that effectively they display with the same height value instead of the spinner height being larger than the list item display height?

推荐答案

我在不久前遇到这个问题我自己,而事实证明,我需要使用不同的布局下拉列表和显示

I've run into this issue myself a while ago, and it turned out that I need to use different layouts for dropdown and display

我有这个code:

adapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cGroups,
                new String[] {
                        "name", "_id"
                }, new int[] {
                    android.R.id.text1
                });
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

这篇关于如何管理Android的微调项目的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆