How to disable the keyboardAvoidingView behaviour in TextInput - android

I am working on a react native project made using react native cli. The problem is that the TextInput gets highlighted when the keyboard is visible/active & it squeezes the view and mess up the layout which reminded me of KeyboardAvoidingView behaviour. Even though I don't use KeyboardAvoidingView in this project because all text inputs are in the upper half of the screen so they won't get covered by the keyboard.
<TextInput
style={styles.inputText}
multiline={false}
onSubmitEditing={() => Keyboard.dismiss()}
autoCapitalize="none"
autoCorrect={false}
keyboardType="number-pad"
onChangeText={numberInputHandler}
value={enteredValue}/>
inputText: {
borderBottomColor: "white",
borderBottomWidth: 2,
width: "30%",
position: "absolute",
bottom: Dimensions.get("window").height / 5,
left: Dimensions.get("window").width / 5,
color: "white",
fontSize: Dimensions.get("window").height * 0.03,
fontFamily: "Lato-Regular"
}
React Native Ver 0.61.5
Testing was done on an Android emulator and an Android physical device

As I can see you are using absolute positioning where bottom uses Dimension api to get the height. The problem occurs due to this. Try giving static height rather then fetching from Dimension because when keyboard appears visible window gets shrink causing react to re-render because height changes.
position: "absolute",
bottom: Dimensions.get("window").height / 5,

Solution provided by Nikosssgr:
In AndroidManifest.xml
android:windowSoftInputMode="adjustResize" changed it to "adjustNothing"

Related

How to add shadow only on the bottom View in react native Expo

I need to add a shadow only on the bottom of a component for and android device (expo reac native)
I get it always on the 4 sides.
list: {
display: "flex",
position: "relative",
borderRadius: 5,
margin: 10,
backgroundColor: "#fff",
shadowColor: "#000",
shadowOffset: {
width: 0,
height: 2,
},
shadowOpacity: 0.25,
shadowRadius: 3.84,
elevation: 3,
},
I am trying something like this in my styles but only seems to work: elevation and shadowColor, the rest of the shadow styles do not seem to do anything in my android emulator (maybe in ios it does)
you are correct,
for android the only property available is elevation
rest all properties are ios only. you can check here RN- shadow- props
For ios it will be very easy to add shadow at bottom by just passing
shadowOffset:{
height:-20 // whatever you wanna have
}
But for android, you need to have external packages for it to work like rn-shadow-2
Hope it helps. feel free for doubts

ScrollView not working in Android react native

I want to render a list in a view of specific height with scroll feature, I tried using ScrollView, this works perfect in iOS but the scroll is not working in Android.
<ScrollView
style={{
position: "absolute",
width: "125%",
maxHeight: scale(100),
opacity: 1,
elevation: 100,
marginTop: scale(50),
backgroundColor: themes.snuff,
borderRadius: scale(12),
}}
nestedScrollEnabled
>
{listItems.map((item: any, index: number) => {
return renderItems(item, index);
})}
</ScrollView>
Above is the code, where renderItems is a function which renders a normal text.
If I remove position: "absolute" from the style, the scroll works in android as well, but in my usecase I need the position: "absolute" to render the view at correct position on UI.
Can someone please help here? I tried various solutions that I found on internet, but no luck.

Overlapping React Navigation Header in react native app

Im working in a react native app, for my navigation, I used react-navigation 4, In one of the screens I want to Overlap the react-navigation header with a card component, On android, it's working fine but on iOS I can't get it to work even though I set the card zIndex to a big number it's always hidden by the react-navigation header.
here is the code for my component :
<View style={global.container}>
<View style={styles.info}>
<View style={styles.card}>
<Image style={styles.image} source={app.appLogo} />
</View>
</View>
<View>
and this is the CSS :
card:{
padding:0,
borderRadius: 30,
backgroundColor:"#fff",
position: 'absolute',
top: -70,
zIndex:99,
elevation:5
},
Display on android:
Display on iOS:
Please add zIndex to parent view. In iOS, the zIndex doesn't work for nested parentView. You need to make the parentView has high zIndex, and then target View again.
.container {
zIndex:101
}
.info {
zIndex:100
}

React Navigation TabNavigator swipe disabled: SwipeRow (NativeBase) not rendering correctly [Android]

I use the TabNavigator from react-navigation and have in one Tab a swipeable Component (SwipeRow component from NativeBase). When swiping left or right on that component it shows context menu, so I disabled the swiping Ability from the Tabs in android (iOS is false by default) by declaring swipeEnabled: false in TabNavigator. Well, TabSwiping is now disabled, but all of a sudden, the context menu is not rendered correctly anymore. On Android with swipeEnabled: true and iOS everything works fine!
Screenshots (Card Element swiped to the left):
Android with swipeEnabled: false
iOS (correctly)
Code:
<SwipeRow
leftOpenValue={100}
rightOpenValue={-100}
left={<View style={{flex: 1,
flexDirection: 'column',
justifyContent: 'space-between',
marginTop: 7,
marginBottom: 7,
marginLeft: 3,
marginRight: 3,}}>
<Button>...</Button>
<Button>...</Button>
</View>}
body={<Card > ... </Card>}
right={/* similar to `left` */}
style={{backgroundColor: 'transparent',
padding: 0,
paddingRight:0,
paddingLeft:0,
paddingTop:0,
paddingBottom:0,
margin: 0,
marginTop: 0,
marginLeft: 0,
marginRight: 0,
marginBottom: 0,
borderBottomWidth:0,
flex: 1,
}}
/>
Any ideas why this is happening? Can I disable TabSwiping another way or can I style the menu differently so it gets renders correctly with swipeEnabled: false on android?
I am now pretty sure it is a styling issue. Adding a fixed height to SwipeRow style-prop fixes the problem, flex: 1 (see above) makes the context menu expand over the whole display height. Nevertheless, I dont know what the height of the content will be. For now I try to calculate it pretty close, but I was happier with the solution before swipeEnabled: false. What does disabling this option do to the overall NativeBase Content, Container or Tab component?

Ignore virtual keyboard when positioning views (Appcelerator Android)

I have a view in appcelerator, here is the styling in the TSS file:
"#addTelephoneNumber" : {
bottom: "10dp",
height: "60dp",
width: "100%",
backgroundColor: "#FBB450",
borderRadius: 10
}
I want it to be at the bottom of the screen, however when the keyboard shows, the view moves up. See screenshots below:
Can the keyboard be ignored and overlap the 'Add number' button? I have tried using top and setting it to 90% however same problem. Setting fixed values in dp fixes the issue, however it does not scale correctly on different mobile devices.
There's two properties to configure this behaviour:
Ti.UI.Window.windowSoftInputMode to determine when the soft keyboard shows as well as how the content adjusts to make room.
Ti.UI.View.softKeyboardOnFocus to override the when per (input) view.

Categories

Resources