2011-11-22 3 views
8

나는 한 다음 버튼 :버튼 배경을 어떻게 스케일 할 수 있습니까?

<Button 
android:id="@+id/buttonok" 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
android:drawableLeft="@drawable/back_no_save" 
android:text="OK" /> 

그 성상은 다음과 같습니다

enter image description here

가 어떻게 내 당김과 보여 작은 화살표를 축소 할 수 있습니까?

답변

1

드로어 블이 가리키는 실제 그래픽의 크기를 줄일 수 있습니다.

+2

그것은 좋은 생각이 아니다 있습니다. – breceivemail

+0

ScaleDrawable을 사용하는 것은 어떻습니까? – zienkikk

5

내가 XML에서 당신이 할 수있는 hink하지 않는 시도 할 수 있습니다. 버튼의 크기 조절을 수행 할 수있는 xml 속성은 없습니다. 다음과 같은 방법으로 프로그래밍 방식하지만 그것을 할 수 있습니다 : 당신이 Bitmap.createScaledBitmap 처리하지 않으려면 다음이 가장 좋은 방법은 어떻게 나에게 보인다

Bitmap originalBitmap= BitmapFactory.decodeResource(getResources(), R.drawable.icon); 
Bitmap scaledBitmap=Bitmap.createScaledBitmap(originalBitmap, newWidth, newHeight, true); 
txt.setBackgroundDrawable(new BitmapDrawable(bit)); 
1

당신의 자신의 구성 요소를 만드는 것입니다. 예를 들어 RelativeLayout을 확장하고 ImageView을 입력 할 수 있습니다.

0

나는 이것이 이전 게시물입니다 알지만,이 같은 짓 :

<LinearLayout 
    android:layout_height="wrap_content" 
    android:layout_width="wrap_content" 
    android:padding="16dp" 
    android:id="@+id/XXXXXXXXXXXX" 
    android:orientation="horizontal"> 
    <ImageView 
     android:src="@drawable/XXXXXXXXXXXX" 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:scaleType="centerInside" 
     android:id="@+id/XXXXXXXXXXXXXXXX"/> 
    <TextView 
     android:id="@+id/XXXXXXXXXXXXXX" 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:text="XXXXXXX" 
     android:layout_gravity="center"/> 
</LinearLayout> 
관련 문제