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

时间:2014-01-14 14:58:05

标签: android android-layout

我正在使用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>

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

2 个答案:

答案 0 :(得分:1)

可能不是最好的解决方案,因为不同的设备具有不同的分辨率,但“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>

答案 1 :(得分:0)

尝试使用fill_parent 每个设备都有不同的屏幕尺寸,所以你需要为每个尺寸和分辨率制作不同的飞溅图像我想问题是你使用的是小尺寸(高度宽)的图像,显​​示器很大 所以你需要缩放图像以适应显示尺寸,这可能会使图像像素化