質問

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. Now i've noticed that AutoCompleteTextView widget has a default underline on bottom, and i would remove it. It's possible?

役に立ちましたか?

解決

Just put:

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

inside your view.

EDIT: As @kiya said, nowadays is better to use

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

As it maintains the view size.

他のヒント

android:inputType="textPhonetic"

This will also work properly

android:inputType="textNoSuggestions"

Use the code below if you want to remove the underline and maintain the size:

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

Use the code below if you want to remove the underline and maintain the size: app:boxStrokeWidth="0dp"

=><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帰属
所属していません StackOverflow
scroll top