简体   繁体   English

如何使用SD卡图像路径添加图像并将其应用于个人资料图片图像?

[英]How can I add the image using sd card image path and apply it on the profile picture image?

I have created the following navigation drawer layout but now I want to apply the sd card image on profile picture view. 我创建了以下导航抽屉布局,但是现在我想将sd卡图像应用于个人资料图片视图。 How can I apply it? 我该如何申请?

ScreenShot: 屏幕截图:

在此处输入图片说明

1) Read your image from the sd card: 1)从SD卡读取图像:

File image = new File(Environment.getExternalStorageDirectory().getAbsolutePath() + File.separator + "path_to_your_file");

if(image.exists())
   Bitmap bmp = BitmapFactory.decodeFile(image.getAbsolutePath());

2) Set it into your appropriate ImageView 2)将其设置为适当的ImageView

ImageView imgProfile = (ImageView) findViewById(R.id.your_image_view_id);
imgProfile.setImageBitmap(bmp);

Getting Image from sdcard 从SD卡获取图像

 Bitmap bmp = BitmapFactory.decodeFile(pathName);
    ImageView img;
    img.setImageBitmap(bmp);

  //add permission AndroidManifest
 <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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