【问题标题】:changing size of image inside ImageButton更改 ImageButton 内的图像大小
【发布时间】:2018-03-19 19:15:15
【问题描述】:

我有一个 ImageView 和 ImageButton。我使用位图裁剪了我的源图像,它的大小已经改变,所以我用这个代码为我的 ImageView 来放大它里面的图像:

LayoutParams params1 = new LayoutParams((int) (320.0f * scale), (int) (250.0f * scale));
ImgView.setLayoutParams(params1);

但这不适用于 ImageButton(它只放大按钮,而不是图像)。请帮忙放大按钮内的图片。

【问题讨论】:

    标签: android image imageview imagebutton


    【解决方案1】:

    尝试使用以下代码:

    android:scaleType="fitCenter" 用于缩放android图像。

    <ImageButton
            android:id="@+id/button_topleft"
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="2dp"
            android:layout_marginRight="5dp"
            android:layout_marginTop="0dp"
            android:layout_weight="1"
            android:adjustViewBounds="true"
            android:padding="20dp"
            android:scaleType="fitCenter" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-21
      • 2012-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多