【问题标题】:It is possible to set scaleType for item in layer-list like for imageView?可以像 imageView 一样为 layer-list 中的项目设置 scaleType?
【发布时间】:2018-05-14 10:40:10
【问题描述】:

看截图

上面我有带有图层列表的按钮:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/button_yellow"/>
    <item
        android:top="5dp"
        android:bottom="5dp"
        android:left="5dp"
        >
        <bitmap android:src="@drawable/Export_hell_seidel_steiner"
            android:gravity="center"/>
    </item>
</layer-list>

<Button
        android:layout_width="341dp"
        android:layout_height="143dp"
        android:layout_margin="3dp"
        android:background="@drawable/layer1"
        android:onClick="onClick"
        android:text="" />

下面我有 ImageButton

<ImageButton
    android:layout_width="299dp"
    android:layout_height="129dp"
    android:background="@drawable/button_yellow"
    android:padding="5dp"
    android:scaleType="fitCenter"
    android:src="@drawable/Export_hell_seidel_steiner"
    />

layer-list 有可能达到类似的结果吗?我应该创建我的自定义 BitmapDrawable 类吗?我在 layer-list 中的项目中需要 scaleType = "fitCenter"。

【问题讨论】:

    标签: android android-imageview android-drawable


    【解决方案1】:

    很遗憾,你不能。尝试改变图像的比例

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-29
      • 1970-01-01
      • 1970-01-01
      • 2011-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多