【问题标题】:How to resize bitmap that have in drawable layer-list? Programmatic or in XML如何调整可绘制图层列表中的位图大小?程序化或 XML
【发布时间】:2020-05-20 03:12:20
【问题描述】:

我正在尝试像 https://medium.com/@ssaurel/create-a-splash-screen-on-android-the-right-way-93d6fb444857 这样以正确的方式构建启动画面,因为我必须将我的应用程序图标 .png 文件作为位图放置在可绘制图层列表中

<item
    android:drawable="@color/gray"/>

<item>
    <bitmap
        android:gravity="center"
        android:src="@drawable/logo"/>
</item>

现在我该如何调整这个位图的大小?谢谢...

【问题讨论】:

    标签: java android xml android-layout bitmap


    【解决方案1】:

    无法通过XML重置新的resize,可以确认link

    在代码方法中,有不同的和复杂的方法。想了解更多可以看这个question

     

    但如果你的目标只是改变大小,这可以通过ImageView

    来完成

    如果您想将完整的图像设置为使用 match_parent 到图像视图的屏幕(最适合启动屏幕),此方法比其他方法更容易和更快:

    <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
    
    
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:scaleType="fitXY"
                    android:layout_centerInParent="true"
                    android:src="@drawable/splash_screen" />
    
            </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 2012-03-25
      • 2013-01-21
      • 2011-10-29
      • 1970-01-01
      • 2015-02-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-23
      相关资源
      最近更新 更多