I have problem when I try to set an image to a ImageView
browsed from assets folder. When I place the same image in the drawable folder and use imageView.setImageResource(R.id.image);
it is larger and fits the screen better than the image browsed by the previous method. Is there a way to resize the image so that it fits the screen exactly the same way as usual.
Here is the layout file and the code in java.
AssetManager manager = getActivity().getAssets();
InputStream input = null;
try {
input = manager.open("images/" + mQuestion.getQImage() + ".png");
} catch (IOException e) {
e.printStackTrace();
}
Bitmap image = BitmapFactory.decodeStream(input);
ImageView qImageView = (ImageView) questionView.findViewById(R.id.ImageView_qImage);
qImageView.setImageBitmap(image);
<ImageView
android:id="@+id/ImageView_qImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/questionTopBottomMargin"
android:background="@color/radioButtonStrokeColor"
android:contentDescription="@string/hello_world"
android:padding="1px"
android:scaleType="fitXY" />