question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Android] Cannot hide inner contents when parent <View> has height or width of 0

See original GitHub issue

I’m trying to use LayoutAnimation as a a means of hiding and showing different View elements. If I set height: 0 and overflow: 'hidden', the View’s contents are completely hidden in iOS. The ideas being that using LayoutAnimation, I’ll toggle the height property to make the View elements slide up and down.

On Android though, that’s the not the case. From what I’ve observed, the View will only shrink as small as the inner contents. It won’t clip the inner elements.

I’ve removed the LayoutAnimation piece from my sample code. You can see what I’m talking about here https://rnplay.org/apps/yO0W4Q. The “ViewTwo” text is still visible even though the parent View has a height: 0, flex: 0, overflow: 'hidden'. If you run the demo in iOS, it works as designed. Is there a way around this or is this a bug or limitation on Android? Any suggestions on how to work around it? Thanks!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
jondbmcommented, Jun 23, 2016

A temporary workaround that sometimes works, but not always, is setting the height/width of the view you want to hide to 0.1 instead of 0. For some reason this will hide the contained view when 0 won’t.

0reactions
mkoncommented, Oct 28, 2016

The problem is the bot is pasting the mail body where mkonicek is split in two lines like this

... @mkon=
icek

bildschirmfoto 2016-10-28 um 14 12 41

Which then tags me in a lot of PRs suddenly. Anyway I put your bot on ignore now maybe that helps

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parent height is 0 while child view height > 0 - Stack Overflow
In the code, I show/hide above RelativeLayout by condition then I use transitionToState to transition to above ConstraintSet . Most of time, it ......
Read more >
Build a Responsive UI with ConstraintLayout
When you add a constraint to both sides of a view (and the view size for the same dimension is either "fixed" or...
Read more >
Element.getBoundingClientRect() - Web APIs | MDN
The width and height properties of the DOMRect object returned by the method include the padding and border-width , not only the content...
Read more >
Comparing Various Ways to Hide Things in CSS
You would think that hiding content with CSS is a straightforward and ... If an image tag (or parent element) has a display...
Read more >
Understanding constraints - Flutter documentation
Parent : “You must be from 80 to 300 pixels wide, and 30 to 85 tall.” Widget: “Hmmm, since I want to have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found