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.

Column of elements is not always rendered correctly on Android

See original GitHub issue

Description

On Android, when rendering simple colored rectangles in a column (behind one another) using View components with given height, they are not rendered correctly when the margin of the containing SafeAreaView is changed. Some of the rectangles seem to be displaced in y-direction, leading to overlaps on one end and gaps on the other. How it looks with no margin: Adding margin leads to erroneous rendering: Margin of one:

Used Emulator:

Emulator version: 30.6.5-7324830 (KVM 12.0.0) Android version: 10.0 (Q) - API 29 AVD configuration: Pixel_2_API_29

React Native version:

System: OS: Linux 5.8 Ubuntu 20.04.2 LTS (Focal Fossa) CPU: (4) x64 Intel® Core™ i7-8565U CPU @ 1.80GHz Memory: 826.55 MB / 15.30 GB Shell: 5.0.17 - /bin/bash Binaries: Node: 14.17.0 - /tmp/yarn–1622118726559-0.15310791279573355/node Yarn: 1.22.5 - /tmp/yarn–1622118726559-0.15310791279573355/yarn npm: Not Found Watchman: 20210523.214641.0 - /usr/local/bin/watchman SDKs: Android SDK: Not Found IDEs: Android Studio: Not Found Languages: Java: 14.0.2 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 17.0.1 => 17.0.1 react-native: 0.64.1 => 0.64.1 npmGlobalPackages: react-native: Not Found

Steps To Reproduce

  1. Create a new react-native project
  2. Start an Android emulator
  3. Run the given code in App.js
  4. See the (correct) rendering of the boxes without overlaps or gaps
  5. Change the margin of the SafeAreaView to different values (e.g. 15)
  6. Save and reload to see the changes

Expected Results

Intersection or gap lines appear between the rendered boxes

Code example:

Simply put the following code to your App.js file:

import React from 'react';
import { SafeAreaView, StyleSheet, View } from 'react-native';

const App = () => {
  return (
    <SafeAreaView style={{flexDirection: 'column', margin: 0 }}>
      <View style={styles.box} />
      <View style={styles.box} />
      <View style={styles.box} />
      <View style={styles.box} />
      <View style={styles.box} />
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  box: {
    height: 50,
    backgroundColor: 'blue',
    opacity: 0.5,
  },
});

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:6
  • Comments:5

github_iconTop GitHub Comments

1reaction
matyihubcommented, Jan 12, 2022

@raphaelPloomes trying around with overlapping the different involved objects (by including minimal x-/y-offsets) was actually helpful. But of course this depends on your exact use case.

0reactions
mjericommented, Jan 12, 2022

The issue is still very relevant. Stale bot: please do not close 😄

@raphaelPloomes: we haven’t had a workaround, except trying a plethora of different ways of creating the element structures and finally reaching something that worked. But it’s not a “do this and it’s solved” solution I could share like that 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

Slow rendering - Android Developers
UI Rendering is the act of generating a frame from your app and displaying it on the screen.
Read more >
Debug your layout with Layout Inspector and Layout Validation
The Layout Inspector in Android Studio allows you to debug the layout of your app by showing a view hierarchy and allowing you...
Read more >
Known issues with Android Studio and Android Gradle Plugin
This page tracks known issues with Android Studio Dolphin | 2021.3.1 and Android Gradle plugin 7.3.1. If you experience an issue not already...
Read more >
Lists and grids | Jetpack Compose - Android Developers
If you need to display a large number of items (or a list of an unknown length), using a layout such as Column...
Read more >
GridLayout | Android Developers
If a child does not specify the row and column indices of the cell it wishes to ... For software-rendered snapshots of a...
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