实际上我正在使用相对布局进行 ImageView 。该 ImageView 用于从互联网接收图像到应用程序。我需要的是我可以动态更改特定图像(例如 jpeg)的图像大小和附件(docx、pdf)等的另一个大小。
我对图像使用了 if 条件,对附件使用了另一个 if 条件。现在如何设置接收图像的图像尺寸和接收附件的另一个图像尺寸。我需要动态地做。请注意,我仅对图像和附件使用一个 ImageView 。
<RelativeLayout>
<ImageView>
id=iv
width=wrap content
height=wrap content
</ImageView>
</RelativeLayout>
for class file
if("image/png"){
iv.setImageResource(R.drawable.abc);
or
code to get images from web
}
else if(mimetype("application/pdf")
{
iv.setImageResource(R.drawable.abc)
}
this is the model
Help me out!
最佳答案
/* 请求布局() 当某些事情发生变化时调用此方法 使该 View 的布局无效。 */
imageView.requestLayout();
imageView.getLayoutParams().height = height;
imageView.getLayoutParams().width = width;
引用:https://android--code.blogspot.com/2015/08/android-imageview-set-width-and-height.html
关于android - 如何在android中动态更改特定图像的imageview大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32775767/