Write to /res/drawable/ on the fly?
Everything in the apk will be read only.
And it's even better: android doesn't extract the apk when you install a program, so the size consumed is kept to minimal.
android image save to res/drawable folder
Its not possible.
The following link can be helpful
- Write to /res/drawable/ on the fly?
Saving to drawable folder programmatically in Android
No, it's not possible. "The drawable folder" doesn't exist as a file system folder at runtime - it's part of your (read-only) binary .apk file.
android generate resource on the fly
I think you're looking for the StateListDrawable
class. You can create these in code, add states to it (e.g. your downloaded pressed png file) and then set it to your button with button.setBackgroundDrawable(stateList)
.
Android studio can not detect the source file in res/drawable
Solution - first problem
The resource name must start with a letter (not number).
Solution - second problem
Use just:
@drawable/039_cloud
instead
@drawable/039_cloud/039_cloud
so:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/039_cloud" />
Android Studio
Android Studio is grouping same images, but for different DPIs.
When you choose Android
view, you will have:
But when you will choose Project
you will see "real" project structure:
Adding Images to Drawable Folder from a Server
Quoting Android Engineer RomainGuy
You cannot write to res/drawable.
However you can look for other alternatives like external storage.
Links to consider are
android image save to res/drawable folder
How to convert a Drawable to a Bitmap?
Android: Image save to location
How to set the image from drawable dynamically in android?
Try this:
String uri = "@drawable/myresource"; // where myresource (without the extension) is the file
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
imageview= (ImageView)findViewById(R.id.imageView);
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable(res);
Related Topics
How to Use View.Ontouchlistener Instead of Onclick
How to Use Radiogroup in Listview Custom Adapter
Locationlistener of Network_Provider Is Enabled But , Onlocationchanged Is Never Called
Android Type_Linear_Acceleration Sensor - What Does It Show
How to Get Android Device Screen Size
How to Set Text in an Edittext
How to Style the Standard React-Native Android Picker
How to Change Focus Color of Edittext in Android
Android Broadcastreceiver, Auto Run Service After Reboot of Device
Make an Android Button Change Background on Click Through Xml
Open Soft Keyboard Programmatically
Programmatically Obtain the Android API Level of a Device
Adb Server Version (36) Doesn't Match This Client (39); Killing