Как отобразить текст подсказки в двух сторонах editText? - PullRequest
0 голосов
/ 15 октября 2018

enter image description here

Как видите, 'email' и 'example@abc.com' находятся на обоих концах EditText. Сначала я хочу использоватьподсказка, чтобы решить это следующим образом:

     android:hint=" email           example@abc.com"   

но я думаю, что это плохой метод.Есть ли несколько хороших способов решить эту проблему.

1 Ответ

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

Как отобразить текст подсказки в двух сторонах editText?

AFAIK , который не встроен в поведение editText, вы можете достичь желаемого результатаиспользуя один editText

РЕШЕНИЕ

Возьмите LinearLayout и оберните EditText и TextView внутри LinearLayout

ОБРАЗЕЦ КОДА

<?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">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:padding="2dp"
        android:orientation="horizontal">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Email" />

        <EditText
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@android:color/transparent"
            android:gravity="end"
            android:text="nilesh@mail.com" />

    </LinearLayout>
</LinearLayout>

ВЫХОД

enter image description here

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