How to set image for imageview and linear layout from Drawable path in android

user3051460

I was successful to load image to linear layout and image from local path as below code

    ImageView imagePerson=(ImageView) findViewById(R.id.imgPerson);
    LinearLayout layoutID=(LinearLayout)findViewById(R.id.layoutID);
    imagePerson.setImageResource(R.drawable.image1);
    layoutID.setBackgroundResource(R.drawable.layout1);

However, I need to save the path of these image in to file. Thus, I cannot use above code to load image to imageview and linearlayout. Instead of this, I want to find the way to load image from path. Could you help me to solve it in android. This is my code to get path

        String pathPerson="drawable://" + R.drawable.imgPerson;
        String pathID="drawable://" + R.drawable.layoutID;

Thanks in advance

Androider

Some ways are:

String imageUri = "drawable://" + R.drawable.image;

Other ways :

Uri path = Uri.parse("android.resource://com.segf4ult.test/" + R.drawable.icon);
Uri otherPath = Uri.parse("android.resource://com.segf4ult.test/drawable/icon");

String path = path.toString();
String path = otherPath .toString();

You can Create a Drawable from a String path like this:

String pathGet = "/path/to/file/myFile.jpg"; 
Drawable d = Drawable.createFromPath(pathGet);

Thanks

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to set image from drawable into imageview in Android

From Dev

How to set a linear layout of buttons at the top of an image (layouts in android)?

From Dev

how to set background image in Linear layout dynamically using Parser in android

From Dev

How to set chosen image from gallery to linear layout using intent?

From Dev

Create dynamic thumbnail image from drawable resource and set to imageView

From Dev

how to set one linear layout below another linear layout in android

From Dev

how to set one linear layout below another linear layout in android

From Dev

Sent a Image from drawable to a ImageView?

From Dev

How to get the drawable from relative layout in android

From Dev

How To Set Image Resource To Android ImageView from Rest API

From Dev

How to open an image in drawable folder using android imageview applications?

From Dev

How to load GIF image from drawable folder into ImageView using glide?

From Dev

Android : set background of layout using image path

From Dev

Android set image from URI on ImageView

From Dev

Android: How to set up Grid Layout inside Linear layout?

From Dev

Set Image to included imageview in a layout

From Dev

Comparing drawable image with imageview icon android?

From Dev

How to tell if ImageView has a set image in android?

From Dev

Android Linear layout image with text

From Dev

Set Linear layout View in Android

From Dev

How to set content in a Linear layout to the BOTTOM of the Screen in Android.?

From Dev

How to set image from PNG based on dynamic drawable name

From Dev

how to set android ImageView visibility inside an included layout?

From Dev

How to load an image from dataurl in android imageview?

From Dev

How to display the image from database in android imageview

From Dev

How to display the image from database in android imageview

From Dev

How to stop an image from squishing into an imageview in android

From Dev

Android: How to set images to Imageview from Video

From Dev

getting an image path from a imageview?

Related Related

  1. 1

    How to set image from drawable into imageview in Android

  2. 2

    How to set a linear layout of buttons at the top of an image (layouts in android)?

  3. 3

    how to set background image in Linear layout dynamically using Parser in android

  4. 4

    How to set chosen image from gallery to linear layout using intent?

  5. 5

    Create dynamic thumbnail image from drawable resource and set to imageView

  6. 6

    how to set one linear layout below another linear layout in android

  7. 7

    how to set one linear layout below another linear layout in android

  8. 8

    Sent a Image from drawable to a ImageView?

  9. 9

    How to get the drawable from relative layout in android

  10. 10

    How To Set Image Resource To Android ImageView from Rest API

  11. 11

    How to open an image in drawable folder using android imageview applications?

  12. 12

    How to load GIF image from drawable folder into ImageView using glide?

  13. 13

    Android : set background of layout using image path

  14. 14

    Android set image from URI on ImageView

  15. 15

    Android: How to set up Grid Layout inside Linear layout?

  16. 16

    Set Image to included imageview in a layout

  17. 17

    Comparing drawable image with imageview icon android?

  18. 18

    How to tell if ImageView has a set image in android?

  19. 19

    Android Linear layout image with text

  20. 20

    Set Linear layout View in Android

  21. 21

    How to set content in a Linear layout to the BOTTOM of the Screen in Android.?

  22. 22

    How to set image from PNG based on dynamic drawable name

  23. 23

    how to set android ImageView visibility inside an included layout?

  24. 24

    How to load an image from dataurl in android imageview?

  25. 25

    How to display the image from database in android imageview

  26. 26

    How to display the image from database in android imageview

  27. 27

    How to stop an image from squishing into an imageview in android

  28. 28

    Android: How to set images to Imageview from Video

  29. 29

    getting an image path from a imageview?

HotTag

Archive