【问题标题】:Image appears different on Android Marshmallow and Android Nougat图像在 Android Marshmallow 和 Android Nougat 上显示不同
【发布时间】:2018-03-09 23:30:59
【问题描述】:

我有我的徽标的 .svg 文件。我使用 android studio 中的矢量资源将 svg 文件转换为 xml 文件。现在,当我在图像视图中使用 xml 文件时。具有 Nougat 的设备可以完美显示图像,但具有 Marshmallow 及更低版本的设备显示不同的图像。

这就是它的外观以及它在装有 Android Nougat 的设备中的显示方式

但这就是它在装有 Android Marshmallow 的设备上的外观。

这是我的 xml

<?xml version="1.0" encoding="utf-8"?>
 <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"
android:background="@color/white"
>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    >

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:src="@drawable/ic_logo"
        android:layout_marginLeft="@dimen/margin_20"
        android:layout_marginRight="@dimen/margin_20"
        android:scaleType="fitXY"
        />

    <TextView
        android:id="@+id/tvOnlineTailor"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="@string/text"
        android:textColor="@color/black"
        android:textSize="20sp"
        android:gravity="center"
        />

</LinearLayout>

</RelativeLayout>

如何解决这个问题? 我知道我可以使用 png 图像而不是 xml 文件,但我不希望图像像素化。

提前致谢。

【问题讨论】:

标签: android image imageview android-6.0-marshmallow android-7.0-nougat


【解决方案1】:

尝试使用 app:srcCompat="@drawable/ic_logo" 代替 android:src="@drawable/ic_logo"

干杯。

【讨论】:

  • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
猜你喜欢
  • 2017-11-23
  • 1970-01-01
  • 2018-12-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-02-26
相关资源
最近更新 更多