I have an ImageView and an extern image which gets load into the ImageView on start. The problem is: the image doesn't have the height of the device. The width is correctly full size. How can I achieve the image to be as high as the deviceheight so that it is fullscreen?
If you don't care about aspect ratio , use
android:adjustViewBounds="false"
android:scaleType="fitXY"
Or if programatically...
ImageView imageView = (ImageView)v.findViewById(R.id.fullImage);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
Hope this helps...
Try this
Display mDisplay= activity.getWindowManager().getDefaultDisplay();
int width= mDisplay.getWidth();
int Height= mDisplay.getHeight();
You can get the device height and set the imageview's height programmatically.
imageView.getLayoutParams().height = Height;
First set width and height of your imageview to match_parent
There are few scale type provided by imageview widget in android :
out of which, I use centerCrop very often because it maintains the aspect ratio but you can find what suits you better.
android:scaleType="centerCrop"
also don't forget to write this line in your xml :
android:adjustViewBounds="false"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.