A phone screen is not a rectangle you own. There is a notch or a Dynamic Island at the top, a home indicator at the bottom, rounded corners, and on Android a status bar whose height varies by device. Content drawn without accounting for them is clipped, and it looks like a bug because it is one.
Use react-native-safe-area-context, not the SafeAreaView exported from React Native core - the core one is iOS-only and does nothing useful on Android. Wrap your app in SafeAreaProvider once, then either use its SafeAreaView or, better, the useSafeAreaInsets hook. The hook gives you the four inset values as numbers, which lets you apply padding only where you need it: a list that scrolls under the notch looks right, while a list whose content starts under the notch does not.
The keyboard is the other half. When it appears it covers the bottom of the screen, which is usually where the field being typed in is. KeyboardAvoidingView moves content out of the way, and it needs behavior="padding" on iOS and generally "height" or nothing on Android, because the platforms handle the resize differently. For a scrolling form, keyboardShouldPersistTaps="handled" is the setting that stops the first tap after typing being swallowed by the keyboard dismissal.
import { SafeAreaProvider, useSafeAreaInsets } from 'react-native-safe-area-context';
import { KeyboardAvoidingView, Platform, ScrollView, TextInput, View, Text } from 'react-native';
export function App() {
// One provider, at the very top of the tree.
return (
<SafeAreaProvider>
<SignInScreen />
</SafeAreaProvider>
);
}
function SignInScreen() {
// Numbers, so you choose where the padding goes rather than taking it all.
const insets = useSafeAreaInsets();
return (
<KeyboardAvoidingView
style={{ flex: 1 }}
// The platforms resize differently; this is the pair that works.
behavior={Platform.OS === 'ios' ? 'padding' : undefined}
keyboardVerticalOffset={insets.top}
>
<ScrollView
contentContainerStyle={{
paddingTop: insets.top + 16,
// The home indicator needs clearance, and so does the keyboard.
paddingBottom: insets.bottom + 24,
paddingHorizontal: 16,
gap: 12,
}}
// Without this, the first tap after typing only dismisses the keyboard.
keyboardShouldPersistTaps="handled"
>
<Text style={{ fontSize: 24, fontWeight: '700' }}>Sign in</Text>
<TextInput placeholder="Email" keyboardType="email-address" autoCapitalize="none" />
<TextInput placeholder="Password" secureTextEntry />
<View style={{ height: 400 }} />
</ScrollView>
</KeyboardAvoidingView>
);
}
Open this example in the editor and change it. Nothing you type is saved.