如何创建一个内含永久提示的编辑文本 [英] How to create a edit text with a permanent hint inside it

查看:133
本文介绍了如何创建一个内含永久提示的编辑文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我具有其中用户输入量的编辑文本。我想要做的是设置一个TextView值之前它是不是像INR,然后用户用户编辑会在它前面输入金额。我想的EditText看起来像下面的一个。我该怎么做?

 <的EditText
        机器人:ID =@ + ID / Eamnt
        机器人:layout_width =WRAP_CONTENT
        机器人:layout_height =WRAP_CONTENT
        机器人:layout_alignLeft =@ + ID /按钮1
        机器人:layout_alignParentBottom =真
        机器人:layout_marginBottom =180dp
        机器人:EMS =10
        安卓的inputType =numberDecimal


解决方案

尝试使用RelativeLayout的,其中包含一个TextView和一个EditText。我下面的东西,试试吧。

 < RelativeLayout的
  机器人:layout_width =match_parent
  机器人:layout_height =50dp
  机器人:背景=@机器人:可绘制/ editbox_background><的TextView
    机器人:ID =@ + ID / constant_text
    机器人:layout_width =WRAP_CONTENT
    机器人:layout_height =match_parent
    机器人:layout_alignParentLeft =真
    机器人:layout_centerVertical =真
    机器人:重力=center_vertical | CENTER_HORIZONTAL
    机器人:文字样式=大胆
    机器人:文字颜色=#C0C0C0
    机器人:文字=INR
    机器人:背景=@机器人:彩色/透明/><的EditText
    机器人:ID =@ + ID /量
    机器人:layout_width =match_parent
    机器人:layout_height =match_parent
    机器人:layout_toRightOf =@ + ID / constant_text
    机器人:文字颜色=#000000
    机器人:文字样式=大胆
    机器人:背景=@机器人:彩色/透明
    机器人:paddingLeft =5DP
    机器人:文字=100000/>
< / RelativeLayout的>

I have a edit text in which the user enters amount. What I want to do is set a textview value before it that is not editable by the user like "INR" and then the user will enter the amount in front of it. I want edittext to look like the below one. How can I do that?

<EditText
        android:id="@+id/Eamnt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/button1"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="180dp"
        android:ems="10"
        android:inputType="numberDecimal"

解决方案

Try to use RelativeLayout which contains a TextView and an EditText. I did something below, try it.

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="50dp"
  android:background="@android:drawable/editbox_background" >

<TextView 
    android:id="@+id/constant_text"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_centerVertical="true"
    android:gravity="center_vertical|center_horizontal"
    android:textStyle="bold"
    android:textColor="#C0C0C0"
    android:text="INR"
    android:background="@android:color/transparent" />

<EditText 
    android:id="@+id/amount"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_toRightOf="@+id/constant_text"
    android:textColor="#000000"
    android:textStyle="bold"
    android:background="@android:color/transparent"
    android:paddingLeft="5dp"
    android:text="100 000" />


</RelativeLayout>

这篇关于如何创建一个内含永久提示的编辑文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆