2012-10-30 2 views
2

사용자가 금액을 입력하는 편집 텍스트가 있습니다. 내가하고 싶은 일은 "INR"과 같이 사용자가 편집 할 수없는 textview 값을 설정 한 다음 사용자가 그 앞에 금액을 입력하는 것입니다. 나는 아래처럼 보이는 edittext를 원한다. 어떻게해야합니까?영구 힌트가있는 편집 텍스트를 만드는 방법

enter image description here

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

답변

13

시도는 텍스트 뷰와 글고을 포함 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> 
+1

이것은 내가 원하는 것이 아닙니다 .. 이미지를 확인하십시오 .. 텍스트보기가 편집 텍스트 안에 있습니다. 외부 ... – Audi

+0

텍스트 및 텍스트보기의 배경 편집을 모두 투명하게 설정하고 새 배경을 만들 수 있습니다. 부모 (RelativeLayout) 전체 EditText처럼 보이게하려면 – osayilgan

+0

내 편집 된 답변을 참조하십시오. – osayilgan

0

텍스트 입력을위한 TextView (힌트 용) 및 EditText를 포함하는 RelativeLayout을 사용할 수 있습니다. 이 코드는 예를 보여줍니다

<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> 
0

나의 제안은 당신이 원하는 텍스트를 그리는 배경 그림을 사용한다. 사용자가 입력 할 수있는 곳을 제한하려면 9 패치를 사용하십시오. 이것은 힌트가 아니지만 문제를 슬프게 할 수 있습니다. Like this one, hope it helps

+0

실제로 내가 생각하기에, 당신이 정말로 필요로하는 것은 암시가 아니며 배경이어야합니다. –

관련 문제