FAQ about Android
In Android, how does one use ViewPager to fill the dynamically created ImageView screen?
Recently, when I was doing something, I had to fill the screen with the picture used for Carousel in ViewPager. But the problem encountered in the middle was that there was always a gap between the ImageView and the screen, as shown in:
At that time, LayoutParam was used in the first response, but it was fruitless after several attempts. Later, I found a solution on the Internet, as long as the ImageView was created, set the ScaleType attribute of ImageView to FIT_XY and solve the problem. The specific code is as follows:
Solution 1:
ImageView imageView = new ImageView (context );
ImageView. setScaleType (ScaleType. FIT_XY); // fill the screen
Solution 2:
<Com. huicuitongkeji. ysb. instructions. viewPagerCompate android: id = "@ + id/viewpager" android: layout_width = "match_parent" android: layout_height = "match_parent" android: scaleType = "fitXY"/>
Then the gap in does not exist.
Reproduced to: http://www.th7.cn/Program/Android/201409/279093.shtml