试试自己 - 用 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>