pedrovgs/Shot

Allow null heights to make the screenshot to wrap content

Open

#110 opened on May 11, 2020

 (6 comments) (2 reactions) (0 assignees)Kotlin (111 forks)github user discovery
enhancementhelp wanted

Repository metrics

Stars
 (1,208 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

This is very useful when taking screenshots of dynamic height views. We don't always force a view to have a height, and the underlying Facebook implementation allows it by simply not setting a height:

/*
     * Measure and layout the view. In this example we give an exact
     * width but all the height to be WRAP_CONTENT.
     */
    ViewHelpers.setupView(view)
      .setExactWidthDp(300)
      .layout();

Expected behaviour

If I send null as height, I want to take a screenshot with WRAP_CONTENT

Actual behaviour

If I send null as height, I have metrics.heightPixels (fullscreen) as a default

Steps to reproduce

compareScreenshot(
                view = view,
                heightInPx = null,
                widthInPx = 600
            )

Version of the library

4.1+, from the moment shot-android wrapper was released.

Contributor guide