天天看点

android imageview 设置图片高度,android – 在ImageView中设置图像宽度和高度

无论我尝试什么,我都无法设置从soap服务传递到我的

android模拟器的图像的宽度和高度.我正在使用

ImageView,如下所示:

byte[] bloc = Base64.decode(result,Base64.DEFAULT);

Bitmap bmp = BitmapFactory.decodeByteArray(bloc,bloc.length);

ImageView image = new ImageView(this);

image.setImageBitmap(bmp);

image.setLayoutParams(

new LinearLayout.LayoutParams(

LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));

image.getLayoutParams().height = 100;

image.getLayoutParams().width = 100;

setContentView(image);

在上面的代码中,我试图手动设置宽度为259像素,高度为194像素的jpeg图像的宽度和高度.

/res/layout/main.xml看起来像

android:orientation="vertical"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:weightSum="1" android:id="@+id/llid">

在尝试下面的答案中的一些方法后,我只是在我的模拟器上看到以下内容

我甚至不确定我采取的方法是否正确.我在搜索论坛时找到的大多数其他解决方案对我不起作用.任何建议都会很棒.