有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java Autocompletetextview建议宽度填充父级

我想显示Autocompletetextview的建议,以填充父级,但在4。它显示的X个设备带有一些透明边框,如屏幕上的:

enter image description here

我的代码如下:

Point pointSize = new Point();
getWindowManager().getDefaultDisplay().getSize(pointSize);
editText.setDropDownWidth(pointSize.x);

以及我的布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:orientation="horizontal" 安卓:layout_width="match_parent"
安卓:background="@color/vanilla"
安卓:layout_height="60dp">

<TextView
    安卓:id="@+id/cityTV"
    安卓:layout_width="wrap_content"
    安卓:layout_height="wrap_content"
    安卓:text="CITY"
    安卓:layout_gravity="center_vertical"
    安卓:layout_marginLeft="54dp"
    安卓:layout_marginStart="54dp"
    安卓:textSize="16sp"
    安卓:textColor="@color/blackTextView"/>

 </LinearLayout>

以及我的autocompletetextview:

<AutoCompleteTextView
        安卓:id="@+id/editText"
        安卓:layout_width="match_parent"
        安卓:layout_height="match_parent"
        安卓:background="#00000000"
        安卓:layout_marginRight="10dp"
        安卓:textSize="18sp"
        安卓:hint="Город"
        安卓:inputType="textFilter|textNoSuggestions"
        安卓:completionThreshold="1"
        安卓:layout_gravity="center_vertical"
        安卓:imeOptions="actionSearch"
        安卓:ellipsize="end"
        安卓:focusable="true"
        安卓:focusableInTouchMode="true"
        安卓:singleLine="true"
        安卓:ems="10"/>

我怎样才能摆脱这些边界,让它真实地显示出来


共 (1) 个答案

  1. # 1 楼答案

    我想我已经找到了答案。如果您想去掉此边框,必须将其添加到AutoCompleteTextView的布局中:

    android:popupBackground="@null"
    

    也许对某些人会有帮助:D