设置编程遥控的ImageView的像素大小? [英] Setting programmatically the pixel size of a remote ImageVIew?
问题描述
让我们说,我有一个包含布局
Let's say that I have a layout that contains
<ImageView
android:id="@+id/my_id"
android:layout_width="123px"
android:layout_height="345px"
android:padding="0dip"
android:scaleType="fitXY" />
这是在一个AppWidget使用,并且经由RemoteViews设置。我如何编程设置像素宽度和高度(覆盖在上面的XML中的123和345)?
which is used in an AppWidget and is set via a RemoteViews. How can I programmatically set the width and height in pixels (overriding the 123 and 345 in the above xml)?
(动机:这个图像视图显示了设置在经由文件URL运行时动态PNG文件如果layout_width和layout_height以上被设定为wrap_content,显示图像按比例缩小的器件的密度()设置。像素精确的宽度和高度,解决了问题,但文件大小的变化,我不知道如何设置它编程)。
(motivation: this image view shows a dynamic png file that is set at runtime via a file URL. If the layout_width and layout_height above are set to wrap_content, the image is displayed scaled down the the device's density(). Setting the exact width and height in pixels solves the problem but the file size changes and I don't know how to set it programmatically).
推荐答案
您可以做到以不同的方式。把你的ImageView在LinerLayout和layout_width设置和ImageView的为FILL_PARENT的layout_height。然后改变的LinearLayout的宽度和高度。
You can do it in a different way. Put your ImageView in a LinerLayout and set layout_width and layout_height of ImageView to "fill_parent". Then change LinearLayout's width and height.
我假设你了解应用小部件的大小规则。
I assume you know about app widgets size rules.
这篇关于设置编程遥控的ImageView的像素大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!