Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Scrollview style height not making any difference

Why does this code create a Scrollview of width 100, but with an unlimited height? Am I missing something obvious? Changing the height value doesn’t change anything.

import { ScrollView } from 'react-native';

export default function App() {
  return (<ScrollView style={{ width: 100, height: 0, backgroundColor: 'red'}}/>);
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You can resolve the height issue by explicitly setting the flexGrow property of the ScrollView to 0 so that the ScrollView to only occupy the space required by its children.

import { ScrollView } from 'react-native';

export default function App() {
  return (<ScrollView style={{flexGrow: 0, width: 100, height: 0, backgroundColor: 'red'}}/>);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading