react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android ListView/ScrollView] Content Padding

Open marcshilling opened this issue 11 years ago • 7 comments

Since it lacks the iOS concepts of contentInset/contentOffset, I realized the correct way to do this is with on Android is adding padding in the ListView/ScrollView styles. But there are a couple issues with this.

  1. The scroll bar/scroll indicator padding is not adjusted accordingly
  2. The content size is not accounted for

Therefore, when I try to set paddingTop: 110 on my ListView, the content is correctly scrolled down by 110, but the scroll indicator still starts at 0, and additionally I am unable to scroll down and see the final 110 pixels of content in my list.

marcshilling avatar Sep 21 '15 19:09 marcshilling

Have you looked at the margin attribute?

aaronechiu avatar Sep 24 '15 13:09 aaronechiu

@AaaChiuuu margin is not the solution because that simply changes the bounds of the entire <ListView>. I want the ListView to take up the full screen, but I want the ListView's content to start 110 pixels from the top (there is a NavigationBar-esque header at the top). The content should be able to scroll all the way to the top. With margin, the content is cut off. The correct solution is padding, it just isn't working at the moment.

marcshilling avatar Sep 24 '15 15:09 marcshilling

I encountered the same problem..

alittlecodebox avatar Dec 16 '15 06:12 alittlecodebox

This can be achieved by setting a padding in the contentContainerStyle prop.

satya164 avatar Dec 24 '15 19:12 satya164

@marcshilling using contentContainerStyle fixed the issue for you?

sibelius avatar Jan 25 '17 12:01 sibelius

I want to use the interpolate function of Animated in my listview's paddingTop. But setting

contentContainerStyle={{paddingTop: this.height.interpolate({
                            inputRange: [0, 44],
                            outputRange: [44, 88]
                        })
                    }}

gives this error on iOS: simulator screen shot 30-jan-2017 2 47 09 pm and while it works on android, it throws this warning for every inner view upto RCTView: screen shot 2017-01-30 at 2 53 06 pm

gitanshu avatar Jan 30 '17 09:01 gitanshu

I think I encountered the same problem. I am adding margin: 30 to contentContainerStyle, but the list doesn't scroll to the bottom: https://snack.expo.io/ryPLeCWxb I think this happens because the margin is not included in scroll height. I can add padding: 30 to contentContainerStyle instead of margin: 30, but then the black border in contentContainerStyle will not be near the white rows. Is it possible to obtain a listview that looks like in my example with margin: 30, but scrolls to the bottom? Maybe to wrap all the rows in a View somehow?

mlazari avatar May 11 '17 11:05 mlazari