【问题标题】:How to select the ideal image size for any screen?如何为任何屏幕选择理想的图像尺寸?
【发布时间】:2021-05-01 21:00:35
【问题描述】:

我正在尝试将图像插入屏幕,但是当我插入一些大图像时,它会出现“位图太大”的错误,而当我插入像 400 x 400 像素这样的小图像时,它会变得模糊。 如何选择准确的图像尺寸,使其看起来不错(不模糊)。

这里是代码

<?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"
     tools:context=".MainActivity2">
     <ImageView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:src="@drawable/non"
         android:scaleType="centerCrop">

     </ImageView>

【问题讨论】:

  • 显示您的代码,以获得更好的帮助
  • 您好,感谢您的回复。我在“Nexus 9”中运行代码。我创建了一个 imageView 并想在其中放置一个图像。当我将比例类型设置为“Centercrop”时,它会变得模糊。当我使用像“Center/Centerfit”这样的任何其他属性时,它不会覆盖整个屏幕。如果我想覆盖整个屏幕,那么可以指导我如何正确选择图像尺寸(高度和宽度)。

标签: android-studio imageview android-imageview image-size


【解决方案1】:

您可以使用矢量图像或为每个 dpi 使用不同大小的光栅图像。

如果可以的话,我建议你使用矢量,因为它更简单、更轻,但如果你不能使用矢量图像,this 会指导你。

【讨论】:

    猜你喜欢
    • 2018-02-09
    • 1970-01-01
    • 2021-05-07
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    相关资源
    最近更新 更多