Подтвердить что ты не робот

Как удалить подчеркивание ниже индикатора EditText?

Недавно мне пришлось изменить цвет индикатора EditText, и после этого над индикатором появилась странная строка. Как я могу удалить это? Код для того, что я сделал, ниже.

введите описание изображения здесь

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                xmlns:card_view="http://schemas.android.com/apk/res-auto"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:background="#4FB6E1">

    <br.com.edsilfer.kiwi.loading.CircularProgressBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        app:colorLine="#4e2972"/>

    <pl.droidsonroids.gif.GifTextView
        android:id="@+id/flying_charizard"
        android:layout_width="100dip"
        android:layout_height="70dip"
        android:layout_above="@+id/login_cluster"
        android:layout_margin="15dip"
        android:background="@drawable/flying_charizard"/>

    <android.support.v7.widget.CardView
        android:id="@+id/login_cluster"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:layout_marginLeft="15dip"
        android:layout_marginRight="15dip"
        android:elevation="4dip"
        card_view:cardUseCompatPadding="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:paddingBottom="10dip"
            android:paddingLeft="10dip"
            android:paddingRight="10dip">

            <include layout="@layout/rsc_util_remove_act_edittext_focus"/>

            <EditText
                android:id="@+id/email"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="E-mail"
                android:imeOptions="actionNext"
                android:inputType="text"
                android:textColor="@color/textSecondary"
                android:textColorHint="@color/textSecondary"
                android:theme="@style/CustomEditText"/>

            <EditText
                android:id="@+id/password"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dip"
                android:hint="Password"
                android:imeOptions="actionGo"
                android:inputType="textPassword"
                android:fontFamily="sans-serif"
                android:textColor="@color/textSecondary"
                android:textColorHint="@color/textSecondary"
                android:theme="@style/CustomEditText"/>


            <com.gc.materialdesign.views.ButtonRectangle
                android:id="@+id/login"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="15dip"
                android:background="@color/textSecondary"
                android:text="@string/act_login_login"/>

            <com.gc.materialdesign.views.ButtonFlat
                android:id="@+id/register"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:layout_marginTop="10dip"
                android:background="@color/textSecondary"
                android:text="@string/act_login_create_account"/>

            <com.gc.materialdesign.views.ButtonFlat
                android:id="@+id/forgotPassword"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center_horizontal"
                android:background="@color/textSecondary"
                android:text="@string/act_login_forgot_password"/>

            <TextView
                android:id="@+id/copyright"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="10dip"
                android:layout_marginTop="5dip"
                android:alpha="0.7"
                android:text="@string/act_login_copyright"
                android:textAlignment="center"
                android:textColor="@color/textSecondary"
                android:textColorHint="@color/textSecondary"
                android:textSize="@dimen/textH4"
                android:textStyle="bold"/>
        </LinearLayout>
    </android.support.v7.widget.CardView>

    <pl.droidsonroids.gif.GifTextView
        android:id="@+id/man_running"
        android:layout_width="60dip"
        android:layout_height="70dip"
        android:layout_alignParentBottom="true"
        android:layout_margin="5dip"
        android:background="@drawable/man_running"
        android:elevation="1dp"/>

    <pl.droidsonroids.gif.GifTextView
        android:id="@+id/background"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:background="@drawable/login_background"/>
</RelativeLayout>

styles.xml

<style name="Theme.AppCompat.Light.NoActionBar.FullScreen" parent="@style/Theme.AppCompat.Light">
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">false</item>
    <item name="android:windowFullscreen">true</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

<style name="CustomEditText" parent="Widget.AppCompat.EditText">
    <item name="colorControlNormal">@color/colorPrimaryDark</item>
    <item name="colorControlActivated">@color/colorPrimaryDark</item>
    <item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>
4b9b3361

Ответ 1

Сделайте такой фон   android:background="@null" вашего editText

Ответ 2

Вы можете установить значение фона Edittext для определенного цвета. Если вы установите прозрачный цвет, нижний план должен исчезнуть.

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

Но это используется только в API уровня 21 или выше

ниже 21

на самом деле довольно просто установить цвет подчеркивания EditText программно (всего одну строку кода).

Чтобы установить цвет:

editText.getBackground().setColorFilter(color, PorterDuff.Mode.SRC_IN);

Чтобы удалить цвет:

editText.getBackground().clearColorFilter();

Примечание: когда в EditText сосредоточено внимание, цвет, который вы установили, не вступает в силу, вместо этого он имеет цвет фокуса.

Справочник по API:

Drawable#setColorFilter

Drawable#clearColorFilter

Это сработало для меня.

Ответ 3

Используйте edittext.clearComposingText(); до getText() или в .xml, вы можете использовать android:inputType="text|textNoSuggestions"

Ответ 4

установите цвет background EditText на белый.

Вы можете установить цвет фона вашего экрана на EditText фон, если оба цвета фона фона и цвет фона EditText совпадают с обозначением EditText подчеркивание не будет видно.

android:background="#FFFFFF" 

Ответ 5

программно я сделал это так:

editText.setBackground(null);

Ответ 6

Android: фон = "@андроид: цвет/прозрачный"

Ответ 7

Если вы используете компоненты материала TextInputLayout, установка цвета фона на что-то другое не удаляет подчеркивание, решение состоит в том, чтобы установить BoxBackgroundMode следующим образом (kotlin): myTextInputLayout.boxBackgroundMode = TextInputLayout.BOX_BACKGROUND_NONE

или в xml: app:boxBackgroundMode="none"

Я думаю, что это изменение в компоненте было сделано, чтобы подчеркнуть "работу" с пользовательским цветом фона

Ответ 8

setColorFilter() не работает на уровнях API 5 и ниже. Один из способов - использовать setBackgroundColor(TRANSPARENT color) и использовать clearColorFilter(), чтобы удалить его.

Ответ 9

Вы также можете определить STYLE для вашего editText, чтобы вы могли перегруппировать все общие свойства. Это очень мощно, если вам нужно многократно редактировать текст, который должен иметь поведение

Поместите код в res/values ​​/styles.xml

<style name="MyEditTextStyle" parent="@android:style/TextAppearance.Widget.EditText">
    <item name="android:background">@color/transparence</item> //NO UNDERBAR
    <item name="android:maxLines">1</item>
    <item name="android:height">28dp</item> //COMMON HEIGHT
</style>

После этого вам просто нужно вызвать его в вашем editText

               <EditText
                android:id="@+id/edit1"
                style="@style/MyEditTextStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />
               <EditText
                android:id="@+id/edit2"
                style="@style/MyEditTextStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

Ответ 10

У меня была такая же проблема, как показано на скриншоте ОП. Решения, описанные в принятом ответе, просто убирают подчеркивание, которое вы хотели настроить. Было бы хорошо унаследовать стиль от Widget.AppCompat.EditText но не от темы. Исправление заключается в удалении наследования из вашего CustomEditText:

<style name="CustomEditText"><!-- parent removed -->
    <item name="colorControlNormal">@color/colorPrimaryDark</item>
    <item name="colorControlActivated">@color/colorPrimaryDark</item>
    <item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>

Кредиты идут на этот ответ

Ответ 11

Если android:background="@null" не помогает - попробуйте объединить его с android:inputType="text|textNoSuggestions"

Полный вид:

    <EditText
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@null"
      android:inputType="text|textNoSuggestions" />