我正在開發一個Android應用程序,該應用程序從一個Web服務獲取基於64編碼的圖像,並將其顯示在ImageView中。在模擬器上顯示但在Android平板電腦上顯示的圖像
我的問題是圖像在模擬器上正確顯示,但是在平板電腦(帶有Android 4的平板電腦ASUS Transformer)上運行時,ImageView在加載圖像時似乎消失。
這是我使用加載的ImageView代碼:
ImageView imageView = (ImageView) this.findViewById(R.id.floor_map_view);
Bitmap image = BitmapFactory.decodeByteArray(result, 0, result.length);
imageView.setImageBitmap(image);
的圖像從Web服務獲得正確的,正如我所說的是正確加載在模擬器和加上我比較收到的基礎64字符串與我的Web服務發送的字符串匹配。
這是我的活動佈局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#ffffff">
<ImageView
android:contentDescription="floorMapView"
android:id="@+id/floor_map_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#222222"
/>
</LinearLayout>
任何想法可能會發生什麼?
謝謝。
編輯:在BitmapFactory.Options對象中使用inSampleSize,並在decodeByteArray調用中使用inSampleSize使圖像顯示,但如預期的那樣,它應該比它小。
是字符串或ByteArray – 2012-04-02 17:14:21
的byte [],否則便無法正常編譯decodeByteArray需要,顧名思義,一個字節數組作爲參數。 – 2012-04-02 17:16:04