【问题标题】:Remove top and bottom black borders from AutoCompleteTextView从 AutoCompleteTextView 中删除顶部和底部的黑色边框
【发布时间】:2020-04-19 19:36:38
【问题描述】:

我在使用 AutoCompleteTextView 下拉组件时遇到问题。

从下图可以看出,弹出窗口中有一些我无法摆脱的黑色边框。

黑边:

我是一个 Android 菜鸟,我基本上已经尝试了所有的方法并取得了成功。

下面的代码,我正在使用。

activity.xml:

<com.google.android.material.textfield.TextInputLayout
                        android:layout_width="0dp"
                        android:layout_height="wrap_content"
                        android:layout_weight="3"
                        android:hint="Categoria"
                        android:layout_marginRight="@dimen/spacing_xlarge"
                        app:hintEnabled="true"
                        app:boxBackgroundColor="@color/white"
                        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu">

                    <AutoCompleteTextView
                            android:dropDownSelector="@color/white"
                            android:id="@+id/private_place_dropdown"
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:dropDownHeight="300dp"
                            android:inputType="none"
                            android:drawableTint="@color/white"
                            android:backgroundTint="@color/white"
                            android:editable="false"
                            android:textColor="@color/piumaBaseColor"
                            />

                </com.google.android.material.textfield.TextInputLayout>

dropdown_menu_popup_item.xml:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:paddingLeft="@dimen/spacing_medium"
    android:paddingRight="@dimen/spacing_medium"
    android:paddingBottom="@dimen/spacing_medium"
    android:ellipsize="end"
    android:maxLines="1"
    android:textAppearance="@style/TextAppearance.MaterialComponents.Body1"
    android:gravity="center_vertical"
    android:background="@color/white"
    android:backgroundTint="@color/white"
    android:textColor="@color/grey_extradark"
    android:text="test"/>

你能帮帮我吗?非常感谢!

【问题讨论】:

  • 你试过background="@null"
  • 刚刚尝试过,但没有任何成功。试图将它基本上放在我使用的组件中的任何地方。
  • 那是微调器还是对话框?你能分享那个 XML 吗?
  • 这是一个下拉菜单,我以编程方式填充它并设置为自动完成 dropdown_menu_popup_item.xml 布局。一切都按照 Material.io 规范完成。
  • 如果可能的话,将您的代码上传到 github 存储库并提供我将检查的链接。

标签: android xml android-layout dropdown autocompletetextview


【解决方案1】:

这条暗线是来自PopupBackgroundView 的附加背景。要解决此问题,只需使用与主题中相同的 surfaceColor 作为背景

<style name="AppTheme" parent="Theme.MaterialComponents.Light">
    ...
    <item name="colorSurface">#FFFFFF</item>
</style>

【讨论】:

  • 这是解决方案:D
猜你喜欢
  • 1970-01-01
  • 2018-06-28
  • 2017-10-22
  • 2023-03-26
  • 2017-12-05
  • 2012-09-12
  • 1970-01-01
  • 1970-01-01
  • 2015-04-24
相关资源
最近更新 更多