Answers for "how to set drawable to imageview in android programmatically"

1

android imageview set image from drawable programmatically

In XML :
    android:background="@drawable/imagename 
    android:src="@drawable/imagename"
    
In Code :
	imageview.setImageResource(R.drawable.imagename);
Posted by: Guest on November-06-2021
0

android display drawable in imageview

img=(ImageView)findViewById(R.id.imageview1);
Drawable myDrawable = getResources().getDrawable(R.drawable.imageView1);
img.setImageDrawable(myDrawable);
Posted by: Guest on April-07-2021
0

how to set drawable name to imageview programmatically

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);
Posted by: Guest on April-21-2020

Code answers related to "how to set drawable to imageview in android programmatically"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language