【发布时间】:2016-08-26 12:58:58
【问题描述】:
我设置单张图片(640x960)如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.imagetest.MainActivity"
tools:showIn="@layout/activity_main">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/launch_image"
android:scaleType="center"/>
</RelativeLayout>
请注意 scaleType 是“中心”,根据文档,这意味着没有缩放。在 Nexus 5x 上运行时,此图像看起来比屏幕大很多,并且只显示了一部分。
我读到了 android 不直接使用分辨率。那么问题是如何计算应该适合特定android设备屏幕而不缩放的图像的大小。
我了解九个补丁图像可用于创建不会扭曲不应缩放的图像部分的启动图像。这个问题部分是为了让我自己更好地了解图像像素与实际设备屏幕的关系,以及是否使用九补丁图像是保证启动图像适用于任何屏幕尺寸的 android 设备的唯一方法。
非常感谢
【问题讨论】:
-
您将此图像放在哪个密度文件夹中?
-
好像您只将图像放在一个文件夹中,例如xhdpi, android 会根据它的密度重新缩放这个图像。因此,图像在 hdpi 屏幕上看起来会更小,而在 xxhdpi 和 xxxhdpi 屏幕上看起来会更大。
-
好问题。我只有可绘制的图像。为什么这会让 640x960 的图像看起来比 Nexus 5x 的屏幕大?
标签: android pixel dpi splash-screen