2014-09-18 3 views
-1

이미지 안에 힌트 텍스트를 넣어야합니다 (예 : "사용자 이름 입력"이라는 힌트 텍스트를 작성해야하는 빈 이미지 이미지 상자가 있음)안드로이드에서 이미지 안에 힌트 텍스트를 배치하는 방법

남자가 이걸 도와주세요 ...

+1

하면 이미지 상자의 코드 예제를 게시 할 수 있습니까? – Martin

+0

당신은'EditText'를 의미하지 않습니까? 사용자가 * 이미지 *에 자신의 이름을 입력하기로되어 있습니까? –

답변

1

"이미지 상자"에는 텍스트를 입력 할 수 없습니다. "사용자 이름"과 같은 것을 입력하려면 EditText를 사용하고 싶을 것입니다.

EditText에 힌트를 표시하려면 XML의 android:hint 또는 Java 코드의 setHint()을 사용하십시오. See documentation.

즉, ImageView 위에 텍스트를 오버레이 할 수 있습니다.

예 :

<RelativeLayout 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 

    <RelativeLayout 
     android:id="@+id/relativeLayout2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerInParent="true"> 

     <ImageView 
      android:id="@+id/imageID" 
      android:contentDescription="@string/content" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerHorizontal="true" 
      android:src="@drawable/image" /> 

    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/relativeLayout3" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_centerInParent="true"> 

     <TextView 
      android:id="@+id/textID" 
      android:contentDescription="@string/content" 
      android:layout_width="250dp" 
      android:layout_height="36dp" 
      android:layout_centerHorizontal="true" 
      android:text="Enter your Username" /> 

    </RelativeLayout> 

</RelativeLayout> 
관련 문제