简体   繁体   中英

Autocompletetextview suggestion width fill parent

I want to show the suggestion of Autocompletetextview to fill parent, but on 4.X devices it is showing with some transparent border like on screen:

在此处输入图片说明

My code is like this:

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

And my layout for it:

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

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

 </LinearLayout>

And my autocompletetextview:

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

How can i get rid of those borders and show it trully match_parent?

I guess I've found the answer. If you want to get rid of this border you have to add this into layout of your AutoCompleteTextView:

android:popupBackground="@null"

Maybe for someone it would be helpful :D

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM