I am using scrollView component to scroll component. It works in local build. But after creating apk file it doesn't work. what can i do.
<View style={{ flex: 1 }}>
<ScrollView contentContainerStyle={{ flexGrow: 1 }} style={{ flex: 1 }}>
<View style={styles.container}>
{
submit ?
isPreview ?
<Text>Preview Page</Text> : <Text style={styles.text}>Thank you!</Text>
: <Questions />
}
<PoweredByPEX />
</View>
</ScrollView>
</View>
i have used View and scrollView component here. i can debug after APK build file. what can i do now. i have used flex layout here. is there any way to sort it out.
Related
I create DropDownPicker in expo app and when open it the items in dropdownmenu can't be selected if it is out of the container view how can fixed as the container view is small part of design
this simple example:
<View>
<View>
some data here.....
</View>
<View style={{ position: "relative", zIndex: 10 }}>
here is the DropDownPicker
</View>
<View>
some data here.....
</View>
</View>
I am using modal from react-native to display a bigger view of an image:
import { Modal } from 'react-native'
<Modal
animationType="slide"
visible={this.state.modalOpen}
presentationStyle="pageSheet"
swipeDirection='down'
swipeThreshold={50}
onSwipeComplete={()=> this.closeImageModal()}
onDismiss={() => this.closeImageModal()}>
<View style={{ flex: 1, backgroundColor: '#121212', justifyContent: 'center', alignItems: 'center'}}>
<TouchableOpacity
style={{padding: 15}}
onPress = { () => this.closeImageModal() }>
<Ionicons name="ios-close-circle" size={30} color="red" />
</TouchableOpacity>
<Image
source={{ uri: this.state.image }}
style={styles.fullScreenImage}
/>
</View>
</Modal>
Right now, I need to press the touchable opacity above the image to close the modal.
I have tried using react-native-modal, and it has been extremely glitchy and difficult to use in my application, so I decided to stick with the modal from react native. Is there any way I can implement swiping down to close with this modal, without having to use react-native-modal?
I am trying to create an Accordian using the component : from library:'react-native-simple-accordian'.
But when the number of accordian headers are more I can't see the ScrollView working correctly.
My code:
<View style={{flex:1}}>
<ScrollView style={{flex:1}}>
<View style={styles.container}>
<SimpleAccordion
style= {{
borderWidth:1,
borderRadius:15,
margin:3,
padding:5,
backgroundColor:'#ffffff'
}}
sections={sectionData}
renderHeader= {this.renderHeader}
renderContent={this.renderContent}
duration={1000}
touchableComponent={TouchableOpacity}
onChange={this.onChangeAccordian.bind(this)}
activeSection={this.state.open}
/>
</View>
</ScrollView>
</View>
The styles object is like this:
container: {
flex: 1,
justifyContent: 'center',
},
What styling or positioning am I doing wrong here for ScrollView?
react-native
You probably need to give style in "contentContainerStyle" prop in case of react-native ScrollView & you may also need to give style property of flexGrow to 1
contentContainerStyle = {{
flexGrow:1
}}
I am trying to align image on top of its container in react native, especially on landscape.
<View style={{flexDirection: 'row', justifyContent: 'center',alignItems: 'center'}}>
<View style={{flex:1,backgroundColor: 'green'}} >
<Image resizeMode='contain'style={{ flex:1,width:"100%",height:"100%"}} source={{uri:"https://www.tageblatt.lu/wp-content/uploads/2020/09/250112_cx__cy__cw__ch_-1-739x493.jpeg"}} />
</View>
<View style={{width:"15%",backgroundColor: 'blue' }}>
<Text style={{color:"white",padding:7}}>{caption}</Text>
</View>
</View>
The output of this code is :
And on landscape:
The desired output is:
Which I get on landscape orientation if I press control+s (saving) on my editor.
I follow this question, but with no solution for me .
I tried different values for resizeMode also .
Have you tried to change the resizeMode ?
<Image resizeMode='cover' ... />
How react native scroll text?
I have a long text in a fixed height container. I want to show a part of text in that container and scroll it when I want to see more.
I have try overflow scroll but react native seems not support overflow scroll.
Thanks.
You can use ScrollView for this case. Just put your text inside it and set height to scroll view.
I'm used the following code. Take ScrollView and put your any element inside ScrollView.
render() {
return(
<View style={styles.container}>
<ScrollView>
<Text>
Add your text
</Text>
</ScrollView>
</View>
);
}
There is currently a limitation in React Native where you can't set height directly on the ScrollView style prop. So, I suggest you do the following if you also want to set the height:
<View style={{ height: 100 }}>
<ScrollView>
<Text>
Your text goes here.
</Text>
</ScrollView>
</View>
Or alternatively using flexGrow:
<ScrollView style={{ flexGrow: 0.2 }}>
<Text>
Your text goes here.
</Text>
</ScrollView>
Relevant issue I found: https://github.com/facebook/react-native/issues/3422
<View style={{ height: hp(3)}}>
<ScrollView>
<Text style={{ fontSize: hp(2) }}>
Your text goes here
</Text>
</ScrollView>