Android get image path from drawable as string

前端 未结 5 606
天涯浪人
天涯浪人 2020-12-04 19:15

Is there any way that I can get the image path from drawable folder in android as String. I need this because I implement my own viewflow where I\'m showing the images by us

5条回答
  •  无人及你
    2020-12-04 19:56

    If you are planning to get the image from its path, it's better to use Assets instead of trying to figure out the path of the drawable folder.

        InputStream stream = getAssets().open("image.png");
        Drawable d = Drawable.createFromStream(stream, null);
    

提交回复
热议问题