4

ユーザーが金額を入力する編集テキストがあります。私がやりたいのは、「INR」のようにユーザーが編集できないテキストビュー値をその前に設定してから、ユーザーがその前に金額を入力することです。edittextを次のようにしたいと思います。どうやってやるの?

ここに画像の説明を入力してください

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

4 に答える 4

15

TextView と EditText を含む RelativeLayout を使用してみてください。私は以下のことをしました、試してみてください。

<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>
于 2012-10-30T08:20:06.950 に答える
0

TextView (ヒント用) を含む RelativeLayout と、テキスト入力用の EditText を使用できます。このコードは例を示しています。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/ll_parent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:text="PasswordHint"
        android:textColor="#aaaaaaaa"
        android:textSize="30dip" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/textView1"
        android:layout_alignBottom="@+id/textView1"
        android:layout_alignParentLeft="true"
        android:background="#00000000"
        android:textSize="30dip" >

    </EditText>

</RelativeLayout>
于 2012-10-30T08:37:57.873 に答える
0

私の提案は、必要なテキストを描画する背景画像を使用することです。9 パッチを使用して、ユーザーが入力できる場所を制限します。これはヒントではありませんが、問題を解決できます。このように、それが役立つことを願っています

于 2012-10-30T08:54:54.450 に答える