如何在xml android中的Button内调整OR缩放图标

时间:2016-02-15 19:03:04

标签: android xml

我有这个简单的xml代码,如何在按钮内调整大尺寸或小尺寸的图像,我需要使用xml更改它。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <Button
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:text="some text"
        android:drawableLeft="@drawable/image"
       />
</LinearLayout>

3 个答案:

答案 0 :(得分:0)

试试这个

CartProduct

答案 1 :(得分:0)

您可以使用Draw 9-patch实现此目的:http://developer.android.com/intl/es/tools/help/draw9patch.html

答案 2 :(得分:0)

有两种可能的方式:

1)使用不同的抽屉尺寸,如Agustin Sovoplas建议的那样。

2)创建水平LinearLayout,其中包含2个视图 - 将图像设置为背景,使用相应文本设置TextView。之后为此LinearLayout设置OnClickListener并像常规按钮一样处理它。