Android RemoteViews,如何在小部件内设置 ImageView 的 ScaleType? [英] Android RemoteViews, how to set ScaleType of an ImageView inside a widget?

查看:45
本文介绍了Android RemoteViews,如何在小部件内设置 ImageView 的 ScaleType?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个在右侧带有图像的小部件,用户可以在其中一个设置屏幕中进行选择.然后可以使用 ImageView.setScaleType("CENTER") 从用户设置图像.那个有效.然后将图像的 URL 作为 URL 存储在首选项中,也作为位图的 Base64 编码字符串(因为我想缩小图像并且用户可以在设置中旋转它)

I am developing a widget with an image on the rigth side, which can be choosen by the user in one of the settings screen. The image can then be set from the user with the ImageView.setScaleType("CENTER"). That works. The URL of the image is then stored in the preferences as URL, and also as Base64 encoded String of the Bitmap (cause I want to shrink the image and the user can rotate it in the settings)

在小部件中,我加载图像.这很好用.使用 URI 和位图.ImageView 的 ScaleType 在 Layout 中也设置为固定值,也可以.

In the widget, I load the image. That works fine. With the URI and with the Bitmap too. The ScaleType of the ImageView is set as well to a fixed value in the Layout, works too.

但是如何以编程方式在小部件中定义 ImageView 的 ScaleType?因为我想将 ScaleType 设置为用户在设置中选择的值.使用 RemoteViews,我们无法获取 ImageView...

我试过了:

myRemoteViews.setString(R.id.myImage, "setScaleType", "CENTER");

myRemoteViews.setString(R.id.myImage, "setScaleType", "CENTER");

<小时>

日志文件说:ImageView 无法使用 setScaleType 函数.


The logfile says: The function setScaleType is not possible for ImageView.

有人知道如何在 AppWidget 中进行这个定义吗?

Does someone know how to make this definition inside the AppWidget?

推荐答案

您可以使用此段以编程方式设置 Image View 的缩放类型..

You can use this segment to set scale type for Image View programatically..

 imgview.setScaleType(ImageView.ScaleType.CENTER_INSIDE);

希望有帮助...

这篇关于Android RemoteViews,如何在小部件内设置 ImageView 的 ScaleType?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆