我正在尝试将可绘制对象缩放到其原始大小的两倍。我正在尝试使用它:Drawable Resouces .我当前的代码是:
可绘制:
<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/ic_launcher"
android:scaleHeight="80%"
android:scaleWidth="80%" >
</scale>
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/scale2" />
</LinearLayout>
但是第二个 ImageView 中没有显示任何内容。我该如何解决?
最佳答案
一旦我遇到这个问题,我就通过使用插图而不是比例尺找到了解决方案。 在 drawable 文件夹中创建一个新的 xml drawable 文件并添加如下代码:
<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/buttonright"
android:insetTop="4dp"
android:insetLeft="4dp"
android:insetRight="4dp"
android:insetBottom="4dp"
/>
这样使用
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/scale" />
关于android - 缩放 XML 中的可绘制资源 (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14195206/