繁体   English   中英

图片在Android中无法正确缩放。

[英]Image doesn't scale properly in Android.

我正在使用xml drawable:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/splashscreen"
    android:tileMode="disabled" android:gravity="top" >
</bitmap>

这是我在布局中的imageView:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ImageView
        android:id="@+id/splash_image"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY"
         />

</RelativeLayout>

但无论我做什么,它都不适合屏幕,只会在中心显示为小图像。 我要去哪里错了?

也许不是最佳解决方案,因为不同的设备具有不同的分辨率,但是“ wrap_content”将以原始分辨率显示图像。

 <RelativeLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

        <ImageView
            android:id="@+id/splash_image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/splashscreen"
        />
    </RelativeLayout>

尝试使用fill_parent每个设备的屏幕尺寸都不同,因此您需要针对每种尺寸和分辨率制作不同的启动图像,我想问题是您使用的是较小尺寸(高度宽度)的图像,并且显示较大,因此您需要将图像缩放到适合显示尺寸,这可能会使图像像素化

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM