在“设置”中更改显示大小时,避免扩大图像资源

时间:2020-03-11 23:00:09

标签: android android-layout android-constraintlayout

我设计的布局具有png图像,当“设置”->“显示设置”->“显示大小”为默认值时,该图像可以正确显示。当设置更改为最大时,图像将按比例放大。我验证了在两种情况下都为我测试的设备选择了xxxhdpi资源,但是当更改显示尺寸时,图像的宽度和高度正在增加,如何避免这种情况?

我正在使用如下所示的约束布局

布局文件

<androidx.constraintlayout.widget.ConstraintLayout 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">

<androidx.appcompat.widget.AppCompatImageView
    android:id="@+id/test"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/intro_device_margin"
    android:layout_marginBottom="@dimen/intro_device_margin"
    android:src="@drawable/test"
    app:layout_constraintBottom_toTopOf="@+id/get_started"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/info_text"
    tools:text="Title" />
.....

当默认的显示尺寸来选择: Display size default

选择最大显示尺寸时: Display size largest

0 个答案:

没有答案