AutoCompleteTextView设置高度以填充父级

时间:2018-05-16 05:55:24

标签: android dropdown autocompletetextview

我是Android开发的新手,并自己学习!我只想将AutoCompleteTextView下拉高度设置为填充父级。

我的AutoCompleteTextView XML视图是:

<form [formGroup]="parentFormGroup">
    <input-form-control
        [required]="false"
        [group]="parentFormGroup"
        label="Description"
        name="description"
        controlId="description"
        helpText="Enter the Description"
        [value]="someValue"                    
        (valueChange)="checkParentValidity($event)">
    </input-form-control>
<form>

我还附上了一个屏幕截图,显示了下拉列表的绿色部分只填充了父项的一部分,但是我希望它以高度填充父项。我不知道它是否可能?有人能指出我的可能性吗?

DropDown not filling the parent by its Height

有关额外信息,我将在此处添加完整的布局:

  <AutoCompleteTextView
    android:id="@+id/countries_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="@dimen/_20sdp"
    android:dropDownHeight="match_parent"
    android:ems="10">
</AutoCompleteTextView>

2 个答案:

答案 0 :(得分:0)

在AutoCompleteTextView

中将高度设置为match_parent
<AutoCompleteTextView
android:id="@+id/countries_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/_20sdp"
android:dropDownHeight="match_parent"
android:ems="10">

答案 1 :(得分:0)

如果您在android:dropDownHeight="match_parent"中使用,那么它将在API 8之后工作,而不是它。除非你把固定值像200dp或300dp。

相关问题