princepiero
princepiero

Reputation: 1323

Set custom width height image drawable in Android button

This is what I want to do: customize the image size because it's just a little too big.

I am creating an Android application and in a button, I have the image and text. Now I want to customize the size of the image to fit on the screen. However, I have a difficulty manipulating the image. If I adjust the width and height, it is of the button's. I wanted to adjust the image size. Is this possible?

Here's the code snippet of the button:

<Button
    android:id="@+id/marketBtn"
    style="?android:attr/buttonBarButtonStyle"
    android:layout_width="0dp"
    android:layout_height="match_parent"
    android:layout_gravity="bottom"
    android:layout_weight="1"
    android:background="@drawable/unselected_button"
    android:drawableTop="@drawable/market_icon_0"
    android:gravity="center"
    android:paddingBottom="5dp"
    android:paddingLeft="1dp"
    android:paddingRight="1dp"
    android:paddingTop="5dp"
    android:text="@string/task_bar_lbl_market"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="#FFFFFF"
    android:textSize="10sp" />

Do you have any idea how to do it? Or what are the possible approaches to fulfill this task?

Upvotes: 2

Views: 5261

Answers (1)

kfmes
kfmes

Reputation: 110

Use nine-patch.

you can set stretchable area and padding area.

http://developer.android.com/tools/help/draw9patch.html

Upvotes: 1

Related Questions