leecade / react-native-swiper

The best Swiper component for React Native.
MIT License
10.42k stars 2.34k forks source link

1.5.13 Android swiper content no display #716

Open chenfuwei opened 6 years ago

chenfuwei commented 6 years ago

Which OS ?

Version

Which versions are you using:

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.

ardmn commented 6 years ago

same issues

ardmn commented 6 years ago

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

ardmn commented 6 years ago

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

<View style={{flexDirection: 'column', justifyContent: 'center', alignItems: 'center',}}>
MacKentoch commented 6 years ago

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 commented 6 years ago

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

timbrandin commented 6 years ago

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

xardit commented 6 years ago

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
mursang commented 6 years ago

@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.

xardit commented 6 years ago

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

appielife commented 6 years ago

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

marcosmartinez7 commented 6 years ago

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?

yaraht17 commented 6 years ago

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.

bhargav-bkpatel commented 6 years ago

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>
    );
  }
sumitk commented 6 years ago

index_js_ _quotes-2

Comment above 2 lines to get offset working.

peteroid commented 6 years ago

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

<Swiper
  containerStyle={{ alignSelf: 'stretch' }}>
  <View />
</Swiper>
MewX commented 6 years ago

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

Thank you all!