天天看點

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">

在嘗試下面的答案中的一些方法後,我隻是在我的模拟器上看到以下内容

我甚至不确定我采取的方法是否正确.我在搜尋論壇時找到的大多數其他解決方案對我不起作用.任何建議都會很棒.