Android 小部件图像的大小
我有一个我不想缩放的图像,我正在使用fitStart。我需要制作多大尺寸才能确保它覆盖4x2小部件?我目前有一个图像是1024x768,它没有覆盖 更新: 以下是xml和屏幕截图:Android 小部件图像的大小,android,Android,我有一个我不想缩放的图像,我正在使用fitStart。我需要制作多大尺寸才能确保它覆盖4x2小部件?我目前有一个图像是1024x768,它没有覆盖 更新: 以下是xml和屏幕截图: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/widget_bg_rl" android:layout_width="match_parent" an
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/widget_bg_rl"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/widget_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitStart" />
<LinearLayout
android:id="@+id/current_layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:weightSum="8">
<RelativeLayout
android:id="@+id/city_time_rl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2.5"
android:background="@drawable/rounded_corners_top">
<TextView
android:id="@+id/city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="MECHANICSBURG"
android:textSize="16dp"
android:textColor="@color/dk_blue"
/>
您使用的是
fitStart
,它可以保持图像的纵横比,并确保一维(在本例中为高度)精确匹配。听起来你想要这两个中的一个:
- 如果要填充空间,显示整个图像(并根据需要拉伸),请使用
fitXY
- 如果要填充空间,保持图像的纵横比(并根据需要进行裁剪),请使用
centerCrop
centerCrop
。它就是这样做的。