2012-10-25 3 views
-6

가능한 중복은 :
How to show the text on a ImageButton?이미지 버튼에 텍스트가 보이지 않습니까?

는 XML에 어떤 문제가 있는지

, 나는

<ImageButton 
    android1:id="@+id/btnShowLocation" 
    android1:layout_width="wrap_content" 
    android1:layout_height="wrap_content" 
    android1:layout_alignParentBottom="true" 
    android1:layout_centerHorizontal="true" 
    android1:contentDescription="@string/empty" 
    android1:layout_marginBottom="40dp" 
    android1:src="@drawable/blue_button" 
    android1:background="@null" 
    android1:text = "@string/here_and_now" 
    android1:textColor="@string/black_color" 
    android1:gravity="center" 
    /> 
+1

y를 사용하여 android1? 그 안드로이드 : 안드로이드 1 –

+0

괜찮아요,하지만 안드로이드 1 날 작품

답변

3

당신이 android:text을 사용할 수 없습니다 버튼을 내 텍스트를 볼 수 없습니다 ImageButton 그래서 버튼을 사용하고 배경을 설정하십시오. 예를 들어

:하여 ImageButton 태그에서 text 속성 : 나는 안드로이드를 찾을 수 없습니다

<Button 
    android1:id="@+id/btnShowLocation" 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:layout_gravity="center" 
    android:padding="10dp" 
    android1:text = "@string/here_and_now" 
    android:background="@drawable/blue_button"/> 
+0

왜 우리는 안드로이드를 사용합니까 : 텍스트 ? .. 우리는 할 수있다! –

+1

기본적으로 이미지 버튼에 대한 속성 텍스트가 없으므로 [확인]을 클릭하십시오. (http://developer.android.com/reference/android/widget/ImageButton.html) –

+0

http://stackoverflow.com/ 질문/4457030/how-to-show-the-text-on-a-image 버튼을 사용하면 여기에서 알 수 있습니다 :) –

-1

.

버튼을 사용하고 버튼에 이미지를 넣으려면 "배경"속성을 사용해야합니다.

<Button android:id="@+id/friendsListButton" android:gravity="center" 
     android:layout_height="wrap_content" android:layout_width="wrap_content" 
     android:text="@string/friendsListScreen" android:background="@drawable/blue_button"/> 

이미지를 단추에 표시하려면 위와 같이 이미지를 정의하십시오.

+0

drawableTop, drawableLeft는 내가 drawableTop을 사용하는 경우, 끔찍한 결과를 제공합니다. 텍스트가 내려갑니다. drawableLeft를 사용하면 텍스트가 오른쪽으로 이동합니다 .. –

+1

그래서 drawableTop 또는 아무것도주지 마십시오. 내 대답과 마찬가지로 버튼을 정의하십시오. 버튼이나 텍스트 만 이미지를 원하십니까? –

+0

드로어 블 대신 배경을 사용했습니다. 필요한 결과를 얻었습니다. –

관련 문제