【发布时间】:2013-08-10 00:59:04
【问题描述】:
自己试试吧——用 anyPngYouWant.png 放置一个 ImageView 布局,然后用
制作一个 bitmap.xml<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/anyPngYouWant"
/>
并放入相同的布局..
为什么它们的大小不同?我尝试了许多不同的图像,但在 bitmal.xml 中 wrap_content 的大小仍然与源 png 不同。我只是希望他们是一样的
布局:
<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"
tools:context=".MainActivity" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/anyPngYouWant" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/imageView1"
android:src="@drawable/bitmap" />
</RelativeLayout>
【问题讨论】:
-
为什么需要放到
中而不是直接使用,我觉得使用图片直接放到ImageView中没有问题。 -
你不能使用
.png这样的文件@drawable/anyPngYouWant.png- 它们还不是可绘制资源。 -
因为我需要在 tileMode 中使用它。它在 tileMode 中失真。但即使没有它,它也会被扭曲。我无法使用设计文件,也无法做出正确的布局
-
好的,g00dy,我该如何使用它们?我只需要为 tileMode 设置一个 png 文件。帮帮我
-
在此处查看答案,了解如何将图像文件正确设置为
imageView。