简体   繁体   English

通过 xml 从 AutoCompleteTextView 中删除下划线

[英]Remove underline from AutoCompleteTextView via xml

i have this view:我有这样的看法:

<AutoCompleteTextView
        android:id="@+id/search_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/rect_search"
        android:layout_alignLeft="@+id/rect_search"
        android:layout_alignRight="@+id/rect_search"
        android:layout_alignTop="@+id/rect_search"
        android:hint="@string/search_bar"
        android:textSize="20sp" />

as you can see, this view goes inside another view, rect_search, that is an ImageView.如您所见,此视图位于另一个视图 rect_search 中,即 ImageView。 Now i've noticed that AutoCompleteTextView widget has a default underline on bottom, and i would remove it.现在我注意到 AutoCompleteTextView 小部件底部有一个默认下划线,我会删除它。 It's possible?这是可能的?

Just put:就放:

android:background="@android:color/transparent"

inside your view.在您的视图中。

EDIT: As @kiya said, nowadays is better to use编辑:正如@kiya 所说,现在最好使用

android:backgroundTint="@android:color/transparent"

As it maintains the view size.因为它保持视图大小。

android:inputType="textPhonetic"

这也将正常工作

android:inputType="textNoSuggestions"

如果要删除下划线并保持大小,请使用以下代码:

android:backgroundTint="@android:color/transparent"

Use the code below if you want to remove the underline and maintain the size: app:boxStrokeWidth="0dp"如果要删除下划线并保持大小,请使用以下代码:app:boxStrokeWidth="0dp"

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

    android:id="@+id/textInputLayout2"

    android:layout_width="345dp"
    android:layout_height="65dp"
    android:background="color/transparent"
    android:backgroundTint="@color/transparent"
    app:endIconMode="dropdown_menu"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:boxBackgroundColor="@color/transparent"
      android:scrollIndicators="none"
     app:boxStrokeWidth="0dp"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:startIconDrawable="@drawable/people"
    app:startIconTint="@color/btnbackground">

    <AutoCompleteTextView

        android:id="@+id/autotext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/button_corner_border"

        android:inputType="text"
        android:textColor="@color/darkbringle" />

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

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

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