我有以下小部件:
如果小部件大小 w=h ,则图像可以,但如果不同,则其拉伸。
如何保持比例?调整大小甚至应该可以工作。
我的 XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/Widget"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center" >
<ImageView
android:id="@+id/buttonwidget"
android:src="@drawable/normalwidget"
android:layout_gravity="center"
android:adjustViewBounds="true"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY" >
</ImageView>
如果可能的话,我更喜欢 XML 解决方案而不是 Drawable 代码。