I got this screenshot from a user that says its scroll is displaced in the center as you can see in the image bellow.
I tried using simulator with iPhone XS Max and even my olds iPhone 7 but couldn't reproduce this in anyway. Maybe this is a known bug or something and I was wandering if someone could point me in the right direction.
About the code, I'm using a ScrollView component with the following props:
<View style={{flex: 1}}>
<ScrollView
style={{flexGrow: 1}}
contentContainerStyle={{flexGrow: 1}}
>
// content here
</ScrollView>
</View>
Hello Please try to set absolute position for your scrollview
`<View style={{flex: 1}}>
<ScrollView
style={{flexGrow: 1, position: 'absolute', right: 0, bottom: 0}}
contentContainerStyle={{flexGrow: 1}}
>
// content here
</ScrollView>
</View>`
Related
I want to build BarCode scanner with #capacitor-community/barcode-scanner, On Android it looks totally fine, it calculate proper height of the screen and put overlay button on the bottom of the page. With Iphones it doesn't work like that, each iphone shows button in other place, I tested it on iphone 8,11 and 13. On Iphone 8 button is visible on the bottom but you can see that it is cut and it is possible to scroll down, on iphone11 it is barely visible and on iphone13 it is not visible at all. Anybody knows how to set overlay button to be totally on the bottom of the page without need to scroll down?
{isScanningInProgress ? (
<>
<StyledStopScanBox>
<Button color="primary" variant="contained" size="large" onClick={stopScan}>
Stop Scan
</Button>
</StyledStopScanBox>
</>
) : (
...
)
const StyledStopScanBox = styled(Box)(({ theme }) => ({
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
position: 'absolute',
width: '100%',
top: 'calc(100vh - 75px)',
zIndex: 3,
height: 75,
backgroundColor: theme.palette.background.default
}));
I'm using a multi line TextInput in my react-native application and been stuck on this for a while. I can not get the text to be vertically aligned on IOS devices.
using textAlign='center' puts the text on IOS vertically centered... but it becomes an unwrapped never ending line.
adding multiline={true} negates the vertically aligned text in IOS and puts it at the top of the input.
<TextInput
style={{
width: wp('80%'),
height: hp('25%'),
borderWidth: 1,
borderRadius: 10,
fontSize: RF(3),
}}
textAlign={'center'}
multiline={true}
onChangeText={entry => this.setState({entry})}
value={this.state.entry}
/>
I would like the behavior to be like android in that it shows the placeholder text vertically and horizontally centered and when user inputs more text it starts creating multi lines if needed but always vertically and horizontally centered.
Please see image with android version on left and IOS on right.
Android on left, IOS on right
try adding textAlignVertical={"center"} to textInput's props
Have you tried wrapping the TextInput in a View?
<View style={{ alignItems: 'center', justifyContent: 'center' }}>
<TextInput
style={{
width: wp('80%'),
height: hp('25%'),
borderWidth: 1,
borderRadius: 10,
fontSize: RF(3),
}}
textAlign={'center'}
multiline={true}
onChangeText={entry => this.setState({entry})}
value={this.state.entry}
/>
</View>
Add the attribute paddingTop to your TextInput in your XML file.
Like the title says I would like to create something like the Picker but instead of scrolling between text I would like to be able to scroll between cards that are View components. Is there a way to do this with the built in Picker or is there a npm packet somewhere which achieve this effect?
My code with Picker that is not working and only displaying the label
<View>
<Text>{this.state.language}</Text>
<Picker
selectedValue={this.state.language}
style={{ height: 250, width: "100%",}}
onValueChange={(itemValue, itemIndex) => this.setState({language: itemValue})}>
<Picker.Item label="Java" value="java">
<View>
<Text>HELLO THERE GENERAL KENOBI</Text>
</View>
</Picker.Item>
<Picker.Item label="JavaScript" value="js" />
</Picker>
</View>
This is somewhat the effect I would like to achieve, being able to scroll between cards
Here is the code, it is very simple:
render() {
return (
<View>
<StatusBar hidden={true}/>
<View style={{height:0}}>
<Button>
<Text>this button should disappears</Text>
</Button>
</View>
<View style={{height:400}}>
<Text>other view</Text>
</View>
</View>
);
}
And here is the output screenshot:
As you can see, because the height of the view is 0, so the button's container is invisible, but why is the button still visible?
After some work, I found out that I have to set the 'other view' 's backgroundColor&height to overlap the button, like that:
<View style={{height:400,backgroundColor:'white'}}>
<Text>other view</Text>
</View>
Now the button will be invisible.
It's so strange, just Button component, I have tried several other components, they are all ok, is it a bug of Button?
Thanks Wong Kim Hau for his reminding, the Button component is from 'native-base', not 'react native'
I'm using react-native v0.44.0, native-base 2.1.3
just use the default Button component from 'react-native', it work fine.
I'm attempting to put a floating button over a ListView in my React-Native application on iOS. The appearance is great, but the functionality of my TouchableHighlight is not so great...
<TouchableHighlight
onPress={() => {
this.myAction()
}}>
<View style={styles.floatingCameraButton}>
<Image source={camera_icon} style={styles.cameraIcon}/>
</View>
</TouchableHighlight>
That's my code for the button, and here are my stylings:
floatingCameraButton: {
height: 80,
width: 80,
borderRadius: 40,
backgroundColor: '#aa2222',
position: 'absolute',
bottom: 20,
right: 20,
shadowColor: '#000000',
shadowOpacity: 0.8,
shadowRadius: 2,
shadowOffset: {
height: 5,
width: 5
},
},
For some reason, when the button is touched on the lower portion of the screen, the touch fails to register on the button.
I've tested making the button taller and also moving in up, and both of those are solutions, but not ones I am interested in.
My assumption is that somehow React-Native is masking my touches that occur where the iOS native Tab Bar would be (meaning the bottom 50px). However, I do not have a Tab Bar on the screen, nor have I implemented one. I do have a Navigator that is wrapping the view which my button is in, not sure if that could be the culprit.
Any ideas or help to get my TouchableHighlight to be touchable on the bottom 50px of the screen would be very helpful.
Try applying your styles to the TouchableHighlight itself.
<TouchableHighlight
style={styles.floatingCameraButton}
onPress={() => this.myAction()}>
<Image source={camera_icon} style={styles.cameraIcon}/>
</TouchableHighlight>