【问题标题】:how to set the height for a spinner dropdown list?如何设置微调器下拉列表的高度?
【发布时间】:2016-02-22 15:16:33
【问题描述】:

我应该如何限制微调器下拉的高度?
假设例如:

如果我有一个总共 10 行的微调器下拉菜单,
我只想显示前 3 行,
其余内容应该是可滚动的。

【问题讨论】:

  • @sasikumar 我已经尝试了使用反射的链接中接受的答案。但是,它对我不起作用。使用该答案,我得到一个覆盖整个屏幕的对话框类型下拉列表。
  • 你可以根据你的手机大小调整高度..in that link code height is 500.
  • @sasikumar 我试过了,还是不行。它仍然占据了整个屏幕的高度。

标签: android xamarin.android android-spinner


【解决方案1】:

微调器中没有默认方法来控制要在下拉菜单中显示的项目数。您可以创建自己的微调器。参考这个link,他创建了一个支持setVisibleItemNo (int no) 方法的自定义微调器。你可以试试。我没有测试它。但代码似乎工作。你可以试试看。

/**
 * Set the height of DropDown spinner equal to number of visible rows
 * 
 * @param no
 *            - number (Integer) of visible item row
 */
public void setVisibleItemNo(int no) {
    this.visibleItemNo = no;
    setListViewHeightBasedOnChildren(lv);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-02-20
    • 2010-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多