调整图片大小按钮

3

我有一个按钮,里面放了一张图片...我必须尝试调整按钮内部的图片大小...我该怎么做呢?可以直接从xml代码中调整吗?以下是xml代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/layout_root"
        android:orientation="vertical"
        android:layout_width="250dp"
        android:layout_height="180dp"
        android:paddingLeft="4dip"
        android:paddingRight="4dip"
        android:background="@color/white_trasparent"
        android:weightSum="1">

    <TextView 
        android:layout_height="wrap_content" 
        android:id="@+id/text" 
        android:textColor="@color/grey" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:layout_width="wrap_content" 
        android:layout_marginLeft="15dp">
        </TextView>
    <Button 
        android:layout_width="wrap_content" 
        android:text="Drawable Top" 
        android:id="@+id/Button03" 
        android:drawableTop="@drawable/icon" 
        android:layout_height="wrap_content" 
        android:textSize="10dp">
        </Button>
</LinearLayout>
1个回答

1

如果我对drawableTop/left/bottom/right属性的理解是正确的,那么它不会将您的图像放置在按钮内部,而是会将其放置在按钮的顶部(北侧)。

如果您想在按钮内部放置图像,请查看ImageButton

我认为这两种方法都不能让您仅设置图像的大小(它们将允许您更改整个视图的大小,在本例中为矩形按钮框和其中的图像。)

为了改变图像的大小而不影响按钮框图形的大小,我认为您需要在Photoshop或其他软件中缩小资源图像。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接