Kal*_*van 1 android android-fragments android-view android-relativelayout
实际上,我正在使用相对布局进行图像查看。该图像视图用于从互联网接收图像到应用程序。我需要做的是可以动态更改特定图像(例如jpeg)的图像大小以及附件(docx,pdf)的其他大小等。
我使用if条件作为图片,另一个if条件作为附件。现在,如何设置用于接收图像的图像尺寸和用于接收附件的另一图像尺寸。我需要动态地做。注意我只对图像和附件使用一个图像视图。
<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!
Run Code Online (Sandbox Code Playgroud)
/ * requestLayout()当某些更改使该视图的布局无效时,调用此方法。* /
imageView.requestLayout();
imageView.getLayoutParams().height = height;
imageView.getLayoutParams().width = width;
Run Code Online (Sandbox Code Playgroud)
参考:https : //android--code.blogspot.com/2015/08/android-imageview-set-width-and-height.html
| 归档时间: |
|
| 查看次数: |
6051 次 |
| 最近记录: |