簡體   English   中英

如何從drawableLeft Android中刪除下划線

[英]How to remove underline from drawableLeft android

嗨,我正在使用editText並為圖像添加了drawableLeft。 但是下划線也在圖像下方。

在此處輸入圖片說明

我正在使用以下代碼:

 <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_add_black_24dp"
            android:hint="@string/email"
            android:drawablePadding="10dp"
            android:layout_marginTop="10dp"/>

 <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableLeft="@drawable/ic_add_black_24dp"
            android:hint="@string/password"
            android:drawablePadding="10dp"
            android:layout_marginTop="10dp"
            android:inputType="textPassword"/>

請建議如何刪除在drawableLeft(image)下面的下划線。

沒有任何直接方法可以在EditText中獲得此功能。

你可以像下面這樣使用。

    <?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/text_white"
        android:orientation="horizontal">

    <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_margin="@dimen/_10sdp"
            android:src="@drawable/ic_email"
            android:tint="@color/black"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginStart="@dimen/_10sdp"
            android:hint="email"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toEndOf="@+id/imageView"
            app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

產量

在此處輸入圖片說明

試試這個吧,也許會幫到你。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="8dp"
        android:layout_marginRight="8dp"
        android:src="@drawable/ic_lock_black_24dp" />

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <EditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="password" />

    </android.support.design.widget.TextInputLayout>

</LinearLayout>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM