0

Я хочу поместить некоторый постоянный текст перед EditText и TextView вид виджета в android. Возможно ли использование атрибутов XML или любым другим способом?Поместить постоянный текст перед EditText и TextView

Я хочу написать задачу перед именем задачи, как показано на картинке. Следуйте приведенной ниже ссылке, чтобы увидеть изображение.
https://i.stack.imgur.com/tF0wH.png

+0

Я думаю, что вы хотите в маске edittext? –

+0

Я уже сделал. Я не понимаю, что вы не понимаете. Пожалуйста, внимательно прочитайте сообщение. –

+0

http://stackoverflow.com/questions/10900348/edittext-textchangelistener – Sanjeev

ответ

0

здесь код, чтобы сделать EditText намек на его этикетке после ввода текста внутри него

<android.support.design.widget.TextInputLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      app:hintTextAppearance="@style/TextAppearance.App.TextInputLayout"> 

      <EditText 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="textEmailAddress" 
       android:ems="10" 
       android:id="@+id/login_field_email" 
       android:hint="@string/login_email"/> 
     </android.support.design.widget.TextInputLayout> 

вот TextAppearance.App.TextInputLayout поставил следующий код в style.xml

<style name="TextAppearance.App.TextInputLayout" parent="TextAppearance.AppCompat"> 
    <item name="android:textColorHint">@color/white</item> 
    <item name="android:textColor">@color/white</item> 
    <item name="android:textColorHighlight">@color/white</item> 
    <item name="android:textColorLink">@color/white</item> 

Перед ввод электронной почты Before entering email После ввода электронной почты After entering email

0
<com.github.pinball83.maskededittext.MaskedEditText 
       android:id="@+id/masked_edit_text" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:inputType="number" 
       app:mask="8 (***) *** **-**" 
       app:notMaskedSymbol="*" 
       app:maskIcon="@drawable/abc_ic_clear_mtrl_alpha" 
       app:maskIconColor="@color/colorPrimary" 
       /> 

Как использовать

app:mask = "8 (***) *** **-**"      //mask 
app:notMaskedSymbol = "*"       //symbol for mapping allowed placeholders 
app:replacementChar = "#"       //symbol which will be replaced notMasked symbol e.g. 8 (***) *** **-** will be 8 (###) ### ##-## by default it assign to whitespace 
app:deleteChar = "#"        //symbol which will be replaced after deleting by default it assign to whitespace 
app:format = "[1][2][3] [4][5][6]-[7][8]-[10][9]" //set format of returned data input into MaskedEditText 
app:maskIcon = "@drawable/abc_ic_clear_mtrl_alpha" //icon for additional functionality clean input or invoke additional screens 
app:maskIconColor = "@color/colorPrimary"   //icon tint color 

Для больше вы можете найти здесь https://github.com/pinball83/Masked-Edittext

0

без какого-либо образца кода это трудно ответить. Одним из решений может быть, чтобы совместить вертикальную LinearLayout с horozontal LinearLayout как в этом примере:

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

<TextView 
    android:text="constant Text" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/textView"/> 

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:inputType="textPersonName" 
     android:text="myEditText" 
     android:ems="10" 
     android:id="@+id/editText" 
     android:layout_weight="1"/> 

    <TextView 
     android:text="myTextView" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/textView2" 
     android:layout_weight="1"/> 

    </LinearLayout> 

</LinearLayout> 
0

Вы можете добавить TextView с постоянным текстом вы хотите затем добавить TextView или EditText для ввода

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal"> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:textSize="16sp" 
    android:textColor="@android:color/black" 
    android:text="ConstantText"/> 
<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/editText" 
    android:textSize="16sp" 
    android:textColor="@android:color/black" 
    android:text="UserText"/> 
</LinearLayout> 
0

Используйте RelativeLayout в качестве корневого макета. Поместите текст ниже. Добавьте Linringayout и поместите свой edittext внутри него, расположите linearlayout в правой части текстового поля.

<RelativeLayout 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:padding="10dp" 
    > 


    <TextView 
     android:id="@+id/text1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:layout_marginTop="10dp" 
     android:textSize="17sp" 
     android:text="Task:" /> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/text1" 
     android:orientation="vertical"> 


     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Enter Task Name" /> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Enter Task Priority" /> 

     <EditText 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:hint="Enter Task Details" /> 


    </LinearLayout> 

</RelativeLayout> 

 Смежные вопросы

  • Нет связанных вопросов^_^