正文

使用內(nèi)置Gallery應(yīng)用程序選擇圖像(4)

Android多媒體開發(fā)高級(jí)編程 作者:(美)艾佛瑞


if (heightRatio > 1 && widthRatio > 1) 

               { 

                    if (heightRatio > widthRatio) { 

                         bmpFactoryOptions.inSampleSize = heightRatio;

                    } 

                    else { 

                         bmpFactoryOptions.inSampleSize = widthRatio;

                    } 

               }

               bmpFactoryOptions.inJustDecodeBounds = false;

               bmp = BitmapFactory.decodeStream(getContentResolver().

               openInputStream(imageFileUri), null, bmpFactoryOptions);

               choosenImageView.setImageBitmap(bmp);

          } catch (FileNotFoundException e) {

               Log.v("ERROR",e.toString());

          } 

     } 

   } 

}

需要在項(xiàng)目的layout/main.xml文件中包含如下內(nèi)容:


上一章目錄下一章

Copyright ? 讀書網(wǎng) ranfinancial.com 2005-2020, All Rights Reserved.
鄂ICP備15019699號(hào) 鄂公網(wǎng)安備 42010302001612號(hào)