마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

안드로이드 버튼 이미지 변경

0 추천
xml 에서

<Button

android:id="@+id/btn"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:drawableTop="@drawable/left"

android:text="clear"

/>

이렇게 버튼을 만들었는데요 이걸 코드상에서

이미지를 변화시키려면 어떻게 해야하나요???

setBackground를 사용해보니 이미지가 막 늘어나보이네요... 텍스트도 안나우구요

저위의 속성과 같은데 이미지만 변경하려면 어떻게해야할까요??
부개동지킴이 (590 포인트) 님이 2013년 11월 6일 질문
setbackground 는 배경에 쓰입니다 님이 쓰신건 이미지를 탑에 위치시킨다는 내용이고요 ..엄연히 달라요

1개의 답변

0 추천

public void setCompoundDrawablesWithIntrinsicBounds (int left, int top, int right, int bottom)

Added in API level 3

Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.

Parameters
left Resource identifier of the left Drawable.
top Resource identifier of the top Drawable.
right Resource identifier of the right Drawable.
bottom Resource identifier of the bottom Drawable.

 

건방진프로그래머 (26,630 포인트) 님이 2013년 11월 6일 답변
...