android - 是什么导致此 PNG 渲染不佳?

标签 android image

我有这个代码:

<RelativeLayout
          android:orientation="vertical"
          android:layout_height="match_parent"
          android:layout_width="398px"
          android:layout_marginTop="35px"
          android:layout_alignParentRight="true"  >
          ....
<ImageView
              android:layout_width="373px"
              android:layout_height="222px"
              android:layout_marginTop="35px"
              android:src="@drawable/hairfall_text"
              android:layout_below="@+id/pr_title" />
</RelativeLayout>

它渲染此图像以在我的设备上显示为这样 (准确地说是 P7500 Galaxy Tab 10.1):

enter image description here

这是我的资源文件夹中的实际可绘制对象:

enter image description here

已经用谷歌搜索和穷尽相关信息,我已经将图像的像素格式调整为 ARGB_8888(32 位),还设置了 Activity 的窗口像素格式(getWindow().setFormat(PixelFormat.RGBA_8888);)什么都不做。

我希望有人能对这件事有所了解。非常感谢。

最佳答案

  1. 首先,如果你能做到,而不是为高度和宽度做“Wrap_content”,例如 layout_height="wrap_content"layout_width="wrap_content" 用于您的 ImageView。您也可以为您的 Parent RelativeLayout 执行相同的操作,但 fill_parent
  2. 其次使用"dp"代替"px"。推荐。

LINK用于安卓测量。 如果可行,请尝试此操作。

关于android - 是什么导致此 PNG 渲染不佳?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9528764/

相关文章:

php - 使用 MAMP 时如何将图像添加到 WordPress 主题?

android - 在 webview 中缩放图像以适应父布局高度,因此默认情况下没有滚动。 (安卓)

java - 如何编写 "to the power"和一些文本,如 Java 或 Android 中所示?

java - Oreo 中我自己的 URI 上的 ContentProvider.notifyChange 的安全异常

android - 关于暂停和延期的概念问题

android - 如何将我的日志输出从 logcat 重定向到 Android 设备上的 SD 卡?

javascript - 在 React native 应用程序的屏幕中的不同项目上应用不同的动画

html - 图片显示不正确

image - 查找 Google Container Registry 公共(public)镜像列表

android - 带有 Google API 的 Robolectric - AnnotationFormatError