Rows intersecting and stacking above one another

I designed a layout with some text and icons displayed in rows. While it appears properly on iOS, the rows overlap on Android.

const criteriaList = [
  { id: 0, title: 'Noor', checked: false },
  { id: 1, title: 'Friends & Grades', checked: false },

];

The list is shown in the FilterCriteriaList component.

  return (
    <View style={styles.container}>
      <View style={styles.horizontalLine} />
      {criteriaList.map((item: CriteriaList) => (
        <View key={item.id}>
          <View style={styles.criteriaRow}>
            <Icon
              name={item.checked ? 'dot-circle-o' : 'circle-thin'}
              color="#31C283"
              size={moderateScale(20)}/>
            <Text style={styles.text}>{item.title}</Text>
          </View>
          <View style={styles.horizontalLine} />
        </View>
      ))}
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
  criteriaRow: {
    flexDirection: 'row',
    paddingLeft: moderateScale(25),
    alignItems: 'center',
  },
  horizontalLine: {
    width: '100%',
    height: moderateScale(1),
    backgroundColor: '#f0f0f0',
  },
  text: {
    paddingLeft: moderateScale(15),
    paddingBottom: moderateScale(15),
    marginBottom: moderateScale(15),
    paddingTop: moderateScale(15),
  },
});

This is where I am including the component:

        <View style={styles.filterCriteriaContainer}>
          <Text style={styles.greyHeadingText}>Weitere Filter</Text>
          <FilterCriteriaList/>
        </View>


  filterCriteriaContainer: {
    paddingTop: moderateScale(35),
    zIndex: 1,
  },

SNACK EXPO:

Even though it functions correctly on the web version, the rows overlap on the Android version.

How can I rectify this issue?

iOS:

https://i.sstatic.net/bMUsk.png

Android https://i.sstatic.net/dbPMO.png

Answer №1

It appears that using flex:1 extensively may be causing the issue at hand. Consider trying the following styles for the list, with your existing code commented for reference:

const styles = StyleSheet.create({
  container: {
    // flex: 1,
    //flexDirection: 'column',
  },
  rowContainer: {
    //flex: 1,
    //lineHeight: 10,
    justifyContent: 'center',
  },
  criteriaRow: {
    flexDirection: 'row',
    paddingLeft: moderateScale(25),
    alignItems: 'center',
    paddingVertical: moderateScale(15),
    //  flex: 1,
  },
  horizontalLine: {
    width: '100%',
    height: moderateScale(1),
    backgroundColor: '#f0f0f0',
    //flex:1,
  },
  text: {
    paddingLeft: moderateScale(15),
    //paddingBottom: moderateScale(15),
    //marginBottom: moderateScale(15),
    //paddingTop: moderateScale(20),
    // flex: 1,
  },
});

Answer №2

container is lacking the declaration of display: 'flex'. Remove flex: 1 from all instances of container, rowContainer, criteriaRow, and horizontalLine. To ensure the text aligns properly with the icons, consider removing horizontalLine and using CSS properties borderTop and borderBottom instead. This adjustment was tested on an iPhone.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exploring the benefits of leveraging TypeScript with AWS NodeJS for improved stacktrace visibility over traditional JavaScript

I'm contemplating the idea of transitioning my existing JavaScript codebase to incorporate TypeScript in NodeJS. One aspect that I am concerned about is being able to view the stack trace in AWS CloudWatch (request log) in case an error occurs during ...

Create a function that triggers a fade-out effect on one button when another button is clicked

Hello everyone! I'm still getting the hang of things around here so please be kind. I need some assistance with my weather app project. Specifically, I've created two buttons and I want to make it so that when one is clicked, the other fades to g ...

Exploring the impact of JavaScript tags on website performance in accordance with W3

While researching website optimization strategies today, I came across an article discussing the benefits of moving JavaScript scripts to the bottom of the HTML page. I am curious if this approach aligns with W3C's recommendations since traditionally ...

Customize esLint by incorporating exceptions

My webpack configuration has two required variables that are causing linting errors. Is there a way to create exceptions for specific variables? I need to ignore the variables path and persistentPlugins. My current .eslintrc file is structured as shown ...

axio. to retrieve the information stored in an alternate document

Seeking assistance in utilizing API data in a separate file. I have three files: api.jsx import axios from 'axios'; export const api = (url, data) => { const { path, method } = url; let result ={}; axios({ method: ...

JavaScript's Math.round function does not always produce accurate results

After adding the specified line within the function, the code seems to encounter issues. parseLocalFloatCnt: num = Math.round(num*1.2); Is there a solution available for this problem? Your help is much appreciated. <!DOCTYPE html> <html> < ...

The offset values of $(element) keep increasing indefinitely when they are updated repeatedly

After researching how to utilize JavaScript drag functionality to move elements, the goal is to dynamically adjust the cursor position within a square when dragged. In an attempt to simplify the process and avoid storing x and y offsets as separate variabl ...

Bug allows unauthorized access to password in Bootstrap Password Revealer

Whenever I try to reveal a Bootstrap password using the eye button, my PC freezes. Strangely, an input is automatically added even though there are no codes for it. This auto-increasing input causes my browser to hang and eventually crashes my entire PC. C ...

Compatibility issues with jQuery observed in Firefox and Internet Explorer 11

Check out the code here: jsfiddle demo HTML CODE: <div class="first"> <!-- Part one --> <div class="acord_col"> <div class="img_class" id="exist_site"></div> <div class="intro_text"> </div> </div&g ...

Ways to change the CSS styling of the placeholder attribute within a textarea or input field tag

I am currently working on adjusting the font size of the text within the placeholder attribute of a textarea element. While I have been successful in achieving this using vanilla CSS, I have encountered difficulties when trying to implement the same concep ...

Navigating through states in AngularJS

My application has three states: app, app.devices, and app.devices.device. While the first two states are functioning properly, the app.devices.device state is not working as expected. Here is the code for reference: http://pastebin.com/r1kYuExp http://pa ...

Node.js Buffer problem: How to tackle it

Encountering an issue with buffers in Node.js The constant buffer is defined as follows: var commands = { BufferOne : new Buffer([0XCA, 0X11, 0X00, 0X00, 0X60, 0X01, 0X00, 0X01, 0X08, 0X07, 0X6D, 0X00, 0X00, 0X00, 0X00, 0 ...

Is it possible to prioritize selections in material-ui's autocomplete feature?

material-ui offers an autocomplete feature, but I am struggling to figure out how to automatically select the first option. Does anyone know if this is possible? ...

MaterialUI React components being stacked on top of each other

Currently working on a project with React and MaterialUI. Just about done with the setup, but I've run into an unexpected issue. The problem is that my simple navbar is overlapping the content beneath it. I set up a code sandbox to demonstrate the i ...

Exploring the possibility of designing custom pageload tooltips inspired by jQuery validationEngine's visual style and interface

My website incorporates the jQuery.validationEngine plugin to ensure the accuracy of user input. The tooltips that accompany this validation feature are particularly appealing; they gracefully fade in and vanish when users interact with them. To visualize ...

Struggling with ajax: Converting a JavaScript variable to a PHP variable

I'm trying to convert a JavaScript variable into a PHP variable in order to use it in an SQL query, but for some reason it's not working as expected. Here is the HTML code: <select id = "dep_ID" name = "dep_ID" onchange="myFunction()"> A ...

CSS code for vertical navigation arrows to remain on both the left and right sides of the webpage

I'm struggling a bit with the CSS. I want to recreate the same effect as seen on . The left and right navigation arrows stay fixed vertically even when scrolling up or down the page. Does anyone have any code examples for that? ...

Accessing a variable from another HTML using JavaScript

I'm currently attempting to access a variable from another HTML file using JS. Specifically, I have a file (file1.htm) that opens a dialog box, and I want to send the information of the selected file to another file (file2.htm) in order to modify a v ...

Jasmine tests for AngularJS directive failed to invoke the link function

I can't figure out why the link function of my directive isn't being called in a Jasmine test. I've created a simple example to illustrate. Here is the code for my directive (TestDirective.js): 'use strict'; angular.module(&ap ...

Exclude certain packages from being processed in webpack

After setting up my webpack configuration, everything was running smoothly with the specified packages in the package.json: { "peerDependencies": { "react": "16.13.1", "react-dom": "16.13.1", ...