首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何计算特定android设备的闪屏图片大小

如何计算特定android设备的闪屏图片大小
EN

Stack Overflow用户
提问于 2016-08-26 20:58:59
回答 1查看 284关注 0票数 0

我设置了单个图像(640x960),如下所示:

代码语言:javascript
复制
<?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设备的屏幕而不进行缩放。

我知道九补丁图像可以用来创建不会扭曲不应该缩放的图像部分的启动图像。这个问题在一定程度上是为了更好地理解图像像素与实际设备的屏幕之间的关系,以及使用Nine Patch图像是不是保证启动图像在任何屏幕尺寸的android设备上都能工作的唯一方法。

非常感谢

EN

回答 1

Stack Overflow用户

发布于 2016-08-26 21:01:13

scaleType centerInside应该可以做到这一点,而不必在代码中进行计算

代码语言:javascript
复制
<ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/imageView"
        android:src="@drawable/launch_image"
        android:scaleType="centerInside"/>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/39166936

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档