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

1.5.13 Android swiper content no display

Open chenfuwei opened this issue 8 years ago • 16 comments

Which OS ?

Version

Which versions are you using:

  • react-native-swiper v?
  • react-native v0.?.?

Expected behaviour

Actual behaviour

How to reproduce it>

To help us, please fork this component, modify one example in examples folder to reproduce your issue and include link here.

Steps to reproduce

1. 2. 3.

chenfuwei avatar Jan 24 '18 09:01 chenfuwei

same issues

ardmn avatar Jan 27 '18 03:01 ardmn

In my case swipeview not show content if it in scrollview ...

ardmn avatar Jan 28 '18 14:01 ardmn

Or no. If I add swipe into view then swipe not show content:

<View style={{flexDirection: 'column', justifyContent: 'center', alignItems: 'center',}}>

ardmn avatar Jan 28 '18 15:01 ardmn

same case as @ardmn .

Won't display content on android if Slider inside a ScrollView.

W/ViewPager: Requested offscreen page limit 0 too small; defaulting to 1

MacKentoch avatar Feb 04 '18 08:02 MacKentoch

I love both iOS and Android. But why the hell do people neglect Android so much? It seems like some kind arrogance from iOS users...

For my concern I found a reliable fix: I just use a better maintained lib: https://github.com/archriss/react-native-snap-carousel

MacKentoch avatar Feb 04 '18 08:02 MacKentoch

I just noticed I needed to set the width of the Swiper in Android for it to display.

timbrandin avatar Feb 04 '18 16:02 timbrandin

Fixed it on Android and IOS At src/index.js comment the parts of curly brackets for the platform if statement This happens because of the component ViewPagerAndroid which is used only on android, the added comments ensure to use ScrollView for both IOS and Android

screen shot 2018-03-06 at 01 28 31

xardit avatar Mar 06 '18 00:03 xardit

@a3diti I did that, but I am getting the error:

_this.scrollVIew[(intermediate value)(intermediate value)(intermediate value)] is not a function

EDIT: I got it working. My slide was like this:

<View key={data.id}>
<TouchableOpacity style={{flex: 1}} onPress={()=>{}}>
<Text></Text>
<Image/>
</TouchableOpacity>
</View>

Just removed: flex:1 on button's style, and got it working. No need to edit the code as @a3diti did. Hope this helps.

mursang avatar Mar 06 '18 12:03 mursang

When using Modal or ScrollViews it does have some issues, so i made a few changes and added a property hasFloatingParent default to false, and i can set it to true when needed Here are the changes of src/index.js https://gist.github.com/a3diti/0c3da7e11d099677a6fbe4987f13513c

@mursang When i remove flex:1 does not fix the issue when using ScrollView inside Swiper childs, or when using a Modal as a parent of Swiper. The problem is simple: Swiper is a blank page when it is inside a Modal

It probably comes from react native component ViewPagerAndroid

xardit avatar Mar 06 '18 13:03 xardit

Still breaking for me . If i am using your code it's not rendering images. Can you check again please. :) @a3diti

appielife avatar Mar 16 '18 06:03 appielife

I had the same problem in Android and inside a model. The @a3diti workarround solves it.

Is there any advantage in use ViewPagerAndroid insted of a ScrollView in android?

marcosmartinez7 avatar Mar 16 '18 13:03 marcosmartinez7

I have same problem, and i change ViewPagerAndroid to ScrollView, but a problem ScrollView in Android can't infinity loop. It has stop when i scroll to end of array. I tried fix it in 4 hour but it's impossible.

yaraht17 avatar Apr 19 '18 15:04 yaraht17

I had to add a delay to get mine to work, but yes it works!

  constructor(props) {
    super(props);
    this.state = { showSwiper: false };
  }

  componentDidMount() {
    // Must use this 100-ms delayed swiper workaround to render on Android properly
    setTimeout(() => {
      this.setState({showSwiper: true});
    }, 100);
  }

  render() {
    var exampleSwiper = (
      <Swiper activeDotColor={'white'} loop={false} >
        <View style={{width: 100, height: 100, backgroundColor: 'white'}} />
        <View style={{width: 100, height: 100, backgroundColor: 'white'}} />
        <View style={{width: 100, height: 100, backgroundColor: 'white'}} />
      </Swiper>
    );
    return (
      <Modal presentationStyle={'overFullScreen'}>
        {this.state.showSwiper ? exampleSwiper : null}
      </Modal>
    );
  }

bhargav-bkpatel avatar May 02 '18 12:05 bhargav-bkpatel

index_js_ _quotes-2

Comment above 2 lines to get offset working.

sumitk avatar Jul 17 '18 18:07 sumitk

After struggling a day for this issue, found that adding a containerStyle to <Swiper /> fixed it.

<Swiper
  containerStyle={{ alignSelf: 'stretch' }}>
  <View />
</Swiper>

peteroid avatar Aug 01 '18 18:08 peteroid

@peteroid 's solution is more elegant than @timbrandin 's, but they all worked for me!

Thank you all!

MewX avatar Sep 02 '18 16:09 MewX