在xml位图中调整图像大小 [英] Resize images in bitmap in xml

查看:449
本文介绍了在xml位图中调整图像大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android编程的新手.最近,我开始一个项目,并想为Android应用程序创建启动画面.在遵循本教程之后,我已经阅读并成功实现了启动屏幕.但是,我意识到我的应用程序徽标会延伸到屏幕之外,如下所示:

I am new to Android programming. Recently, I had started on a project and would like to make a splash screen for the Android app. I had read and successfully implemented the splash screen after following this tutorial. However, I realise that my app logo stretches out of my screen, like this:

以下是我的background_splash.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/splash_background" />

    <item>
        <bitmap
            android:gravity="center"
            android:src="@drawable/tap" />
    </item>
</layer-list>

我尝试过

android:width="75sp"
android:height="75sp"

中的

,但它不起作用.因此,除了使用ImageView之外,我想知道是否有一种方法可以调整图像的大小(最好没有Java代码).任何帮助将不胜感激!

in <bitmap> but it does not work. Thus, I would like to know if there is a way to resize the image (without Java code, preferably) except for using an ImageView. Any help would be appreciated!

推荐答案

只需更改

android:gravity="center"

收件人

android:gravity="fill"

这篇关于在xml位图中调整图像大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆