I have searched high and low to try and find an answer for this problem that I'm having. Basically, I have a scrollview with lots of items that are checkboxes. I want to have a few buttons on the bottom that are 'select all' 'select none' type actions. I want the buttons to equally take up the available space (e.g. stretch so that there are no gaps). I've tried a ton of different combinations of styles for the buttons and the containers with no luck.
I have a working example here, but I'll post the code as well for convenience. Any help or direction would be greatly appreciated.
Edit: As suggested, I've looked at ButtonGroup from react-native-elements but I didn't like how the buttons stayed selected. Plus, I feel like this is a common issue that I've yet to find a solution to with flexbox in react native.
https://snack.expo.io/BJNEmvMvQ
import React, { Component } from 'react';
import { View, Text, ScrollView } from 'react-native';
import { CheckBox, ListItem, Button } from 'react-native-elements';
export default class App extends Component {
list = [ list of objects to render checkboxes (see snack for example ];
renderItem = (item, i) => {
return (
<View key={i}>
<CheckBox
title={item.Description}
checkedIcon="check"
uncheckedIcon="times"
/>
</View>
)
}
render() {
return (
<View style={{ flex: 1 }}>
<ScrollView>{this.list.map(this.renderItem)}</ScrollView>
<View style={{ flexDirection: 'row',
justifyContent: 'center' }}>
// have tried in the view style above: flexGrow, alignItems, and others
<Button
title="hello"
containerViewStyle={{ borderWidth: 2,
borderColor: 'black'}}
// have tried using flexGrow, alignSelf
// have also tried using 'buttonStyle' here instead of 'containerViewStyle'
/>
<Button
title="hello"
containerViewStyle={{ borderWidth: 2,
borderColor: 'black' }}
/>
<Button
title="hello"
containerViewStyle={{ borderWidth: 2,
borderColor: 'black' }}
/>
<Button
title="hello"
containerViewStyle={{ borderWidth: 2,
borderColor: 'black' }}
/>
</View>
</View>
);
}
}
