android app load and resize images
I need load image from assets开发者_如何学运维 I can read text file
but i can not read images and get to BitmapFactory my simple codeBitmapFactory.decodeFile(resources.getAssets().open("Untitled-1.jpg"));
Images should be placed in the /res/drawable-XXX
-folders (see this table).
If you put them in the /res/drawable-XX
-folder, you can load them (with Java) using something like this to show it in a ImageView
:
ImageView view = (ImageView) this.findViewById(R.id.drawme);
view.setImageResource(R.drawable.android);
If you need it as a Bitmap
-Object, you can use the decodeResource()-method BitmapFactory
-class:
ImageView image = (ImageView) findViewById(R.id.test_image);
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.icon);
image.setImageBitmap(bitmap);
精彩评论