简体   繁体   English

从AutoCompleteTextView下拉列表中删除阴影

[英]Remove Shadow From AutoCompleteTextView Dropdown

I am trying to create a full width auto complete text field . 我正在尝试创建一个全宽度自动完整文本字段

So far, I think I have the text field itself looking right. 到目前为止,我认为我的文本字段本身看起来正确。 The problem is with the auto complete popup. 问题在于自动完成弹出窗口。 It has this very bold shadow all around it and I just can't get rid of it. 它周围有这个非常大胆的阴影,我无法摆脱它。
Don't get me wrong, I still want the shadow, but a subtle shadow, only on the bottom of the popup, not all around it (especially not at the top, that's really weird). 不要误解我,我仍然想要阴影,但是一个微妙的阴影,只在弹出窗口的底部,而不是周围的所有(特别是不在顶部,这真的很奇怪)。

Something like this: 像这样的东西: 这就是我要的。

Here's what mine looks like (sorry for giant image): 这是我的样子(抱歉巨像): 到目前为止我有什么


The Code 代码

activity_main.xml: activity_main.xml中:

<AutoCompleteTextView
    android:id="@+id/actvSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="8dp"
    android:background="@drawable/full_width_input"
    android:completionThreshold="1"
    android:hint="Search a movie..."
    android:textColorHint="#BDBDBD"
    android:elevation="0dp"
    android:popupBackground="@android:color/white" />

full_width_input.xml: full_width_input.xml:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:top="-1dp" android:right="-1dp" android:left="-1dp">
        <shape android:shape="rectangle">
            <padding android:bottom="20dp" android:top="20dp" android:left="16dp" android:right="16dp" />
            <solid android:color="@android:color/white" />
            <stroke android:width="1dp" android:color="#E0E0E0" />
        </shape>
    </item>
</selector>

This question is a bit old already, but anyways. 这个问题已经有点老了,但无论如何。 I just crossed through this problem. 我刚刚解决了这个问题。 I was using android:popupBackground="@null" for my autocomplete, but it DOES NOT WORK PROPERLY ON ANDROID 6 (I just tested it). 我使用android:popupBackground="@null"作为我的自动完成,但它在ANDROID 6上没有正常工作(我刚刚测试过它)。

Instead of using android:popupBackground="@null" , use android:popupBackground="@android:color/transparent" (it will also work for the Android 4.4 and 5.0). 而不是使用android:popupBackground="@null" ,使用android:popupBackground="@android:color/transparent" (它也适用于Android 4.4和5.0)。

use android:popupElevation="0" 使用android:popupElevation =“0”

<AutoCompleteTextView
    android:id="@+id/actvSearch"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_marginBottom="8dp"
    android:background="@drawable/full_width_input"
    android:completionThreshold="1"
    android:hint="Search a movie..."
    android:textColorHint="#BDBDBD"
    android:popupElevation="0dp"
    android:popupBackground="@android:color/white" />

If we set android:popupBackground="@null" in AutoCompleteTextView and set background for the adapter row as white, we can achieve this. 如果我们在AutoCompleteTextView中设置android:popupBackground =“@ null”并将适配器行的背景设置为白色,我们就可以实现这一点。 Hope it will help you. 希望它会对你有所帮助。

What I ended up doing is manually creating the auto complete using a ListView . 我最终做的是使用ListView手动创建自动完成。

It took a bit of hacking around but now I have the exact design I had in mind. 它需要一些黑客攻击,但现在我有了我想到的确切设计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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