Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ScrollView ignores its border (Screenshots attached)

Trying to set border to ScrollView component. On iOS it works just fine, but not on Android:

 scrollView: {   
   borderColor: '#000000',
   borderStyle: 'solid',
   borderWidth: (1),
 }

Nice black border on iOS:

enter image description here

No black border on Android:

enter image description here

Try here: https://rnplay.org/apps/cJbAjg

like image 225
Ivan Chernykh Avatar asked May 18 '16 09:05

Ivan Chernykh


3 Answers

Can't really explain why, but one of the fixes is the following:

var styles = StyleSheet.create({   
  container: {
    marginTop: 20,
    marginHorizontal: 1,
    borderRadius: 8,
    borderColor: 'black',
    borderStyle: 'solid',
    borderWidth: 1,   
  }, 
  scrollView: {         
    height: 40,   
  },   
  item: {       
    backgroundColor: '#ddd',
    borderRadius: (5),
    padding: 5,
    margin: 5,   
  } 
});

I've tested this on an android device using rn 0.26.0

like image 153
Stefan Turcanu Avatar answered Nov 16 '22 21:11

Stefan Turcanu


Instead of the prop styles use contentContainerStyle

<ScrollView contentContainerStyle={styles.scrollView}></ScrollView>
like image 41
Amir Avatar answered Nov 16 '22 22:11

Amir


<View
style={{overflow : "hidden" , borderRadius : 20}}
>
<ScrollView>
{/*Your other view*/}
</ScrollView>
</View>
like image 39
JASIM TK Avatar answered Nov 16 '22 21:11

JASIM TK