【问题标题】:AutocompleteTextView PopupWindow heightAutocompleteTextView 弹出窗口高度
【发布时间】:2016-11-15 07:45:12
【问题描述】:

我的屏幕顶部有一个AutoCompleteTextView,并使用与AutoCompleteTextView 关联的默认列表来显示我的数据。我的屏幕底部有一个底部导航栏,即使显示建议也可见。

我面临的问题是,当弹出窗口的列表中有太多建议时,它会覆盖我的底部导航栏(列表在底部导航栏的顶部)。我想通过给 PopupWindows ListView 留出余量或者控制 popupWindow 的高度来防止这种情况发生。有一个 API setDropdownHeight(),但没有 marginBottom 或限制视图底部填充整个屏幕的方法。

/**
 * <p>Sets the current height for the auto-complete drop down list. This can
 * be a fixed height, or {@link ViewGroup.LayoutParams#MATCH_PARENT} to fill
 * the screen, or {@link ViewGroup.LayoutParams#WRAP_CONTENT} to fit the height
 * of the drop down's content.</p>
 *
 * @param height the height to use
 *
 * @attr ref android.R.styleable#AutoCompleteTextView_dropDownHeight
 */
public void setDropDownHeight(int height) {
    mPopup.setHeight(height);
}

AutoCompleteTextView 中的 API 提供了使用 anchorverticalOffset 等 API 来执行此列表顶部/开头的选项。但我无法找到用于执行此操作的 API底部。有没有办法做到这一点?

【问题讨论】:

    标签: android autocompletetextview android-popupwindow


    【解决方案1】:

    您可以使用该属性在此小部件的描述中设置此属性:

    enter code here
    
    Point pointSize = new Point();
    
    getWindowManager().getDefaultDisplay().getSize(pointSize);
    
    myAutoCompleteTextView.setDropDownWidth(pointSize.x);
    

    试试这个方法

    【讨论】:

    • 你要我在哪里添加这个?哪种方法会处理这个问题?
    猜你喜欢
    • 2011-10-20
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 2011-10-31
    • 1970-01-01
    • 1970-01-01
    • 2016-05-24
    • 1970-01-01
    相关资源
    最近更新 更多