简体   繁体   中英

Decode an image file path into image and set it to the layout in android

Iam retreiving the file path related to particular image,but the path is not decoded.

Here is my code,

 BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
 bmpFactoryOptions.inScaled = false;
 Toast.makeText(getApplicationContext(), "" +mSignature.file.getPath(), Toast.LENGTH_SHORT).show();
 Bitmap bitmap = BitmapFactory.decodeFile(mSignature.file.getPath(), bmpFactoryOptions);
 Toast.makeText(getApplicationContext(), "" + bitmap, Toast.LENGTH_SHORT).show();
 ivSignature.setImageBitmap(bitmap);

I am getting the path but not the image is set in the layout...Solve the problem.

我认为您的代码是正确的,但是当您想读取SDCard时,是否没有在AndroidManifest.xml添加<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM