FAQ about Android

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.