0

嗨,我有可扩展的图像 url,我想自动适应我正在使用的图像视图。这是我的图像视图代码

<com.livetalkback.xfactor2012.ui.views.CmsRemoteImageView
            android:id="@+id/categoryThumbnail"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:layout_marginLeft="4dp"

            android:src="@drawable/ic_category_thumb_default" />

如果附加具有所需高度和宽度的 url,则其会自动调整但我不想附加硬编码高度和宽度,因为我的应用程序支持多种屏幕尺寸设备。请帮忙

4

3 回答 3

0

您可以尝试通过 id 找到您的 imageViewonCreate(bundle savedInstanceState)并将其源设置为yourWebServiceQueryResult,以便能够使用 eponym 方法以样本大小对其进行解码。

再见

于 2013-01-29T13:07:59.170 回答
0

我假设您的自定义图像视图正在扩展典型的 Android 图像视图。在这种情况下,您可以使用 Scaletype 作为 Fitxy 属性。

更多信息

于 2013-01-29T13:13:20.083 回答
0

我认为您是在获取图像并设置为给定视图,您可以使用查找图像的默认宽度和高度,然后找到它们的纵横比以及您希望缩放的比例,您可以通过矩阵调整它的大小

Matrix matrix = new Matrix();

// resize the bit map

   matrix.postScale(scaleWidth / width, scaleHeight / height);

// recreate the new Bitmap

    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, true);

    bm.recycle();

    return resizedBitmap;
于 2013-01-29T14:21:18.177 回答