Удалить подчеркивание только под значком DrawableStart, используемым в EditText - PullRequest
0 голосов
/ 03 октября 2018

enter image description here

У меня был атрибут TextInputLayout, в котором я установил атрибут DrawableStart, который показывает значок над подчеркиванием EditText, но мне не нужно подчеркивать только ниже нарисованного.Есть ли способ сделать это путем настройки TextInputEditText?

Ответы [ 4 ]

0 голосов
/ 04 октября 2018

Попробуйте это:

, если вам не нужно подчеркивание только ниже нарисованного.чем вы можете использовать фоновый ноль в обоих случаях TextInputEditText и Edit Text следующим образом

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">


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

   <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/email_img"
        android:hint="Email"
        android:paddingLeft="5dp"
        android:drawablePadding="@dimen/margin_10"
        android:background="@null"
        android:inputType="textPassword"/>

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


<android.support.design.widget.TextInputLayout
    android:layout_width="match_parent"
    android:layout_marginTop="@dimen/margin_10"
    android:layout_height="wrap_content">

    <android.support.design.widget.TextInputEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/password_icon"
        android:hint="Password"
        android:paddingLeft="5dp"
        android:drawablePadding="@dimen/margin_10"
        android:background="@null"
        android:inputType="textPassword"/>

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

Вывод:

enter image description here

Надеюсь, это поможет вам

0 голосов
/ 03 октября 2018

Вы идете по этому неправильному пути.Подчеркивание всегда будет включать все TextInputLayout, поскольку подчеркивание является его частью, а не частью изображения.Чтобы добиться того, что вы хотите, чтобы создать LinarLay следующим образом:

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


<ImageView
    android:id="@+id/imageView"
    android:layout_width="88dp"
    android:layout_height="88dp"
    android:scaleType="centerCrop"
    android:src="@drawable/ic_menu_camera"
    android:background="@drawable/bgXMLFileName"/>

<EditText
    android:inputType="text"
    android:id="@+id/some_text"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:textAppearance="?android:textAppearanceMedium"
    android:textColor="#000000"
    />
</LinearLayout>

Теперь создайте еще один XML-файл макета "bgXMLFileName"

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#FFFFFF" />
    <stroke android:width="1dp" android:color="#000000" />
    <padding android:bottom="1dp" />
</shape>

Должен выполнить работу

0 голосов
/ 03 октября 2018
<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>

результат: enter image description here

0 голосов
/ 03 октября 2018

Определите свой значок в ImageView, а затем определите EditText справа от этого значка.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_icon" />

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

        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Password"
            android:inputType="textPassword"/>

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

</LinearLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...