[React Native] Prevent the On-screen Keyboard from Covering up Text Inputs
When you bring up the on screen keyboard in a mobile app, it will cover any text input or buttons on the bottom half of the screen, which can be frustrating for users. There are a few common ways to deal with this in React Native - and this video shows the following solutions:
First, you can use the built in KeyboardAvoidingView to move components around when the keyboard comes on screen. It has the advantage to being built in to React Native already - but it can be overly complicated to get this approach to work consistently across both iOS and Android.
There is also a third party library called KeyboardAwareScrollView, which will allow your entire view to scroll, and will keep the currently selected text inputs up and out of the way of the keyboard.
Install:
npm i -D react-native-keyboard-aware-scroll-view
Use:
import { KeyboardAwareScrollView } from 'react-native-keyboard-aware-scroll-view'
export default class App extends Component {
  render() {
    return (
      <KeyboardAwareScrollView
        style={{ flex: 1 }}
      >
          <View style={styles.loginHeader}>
            <Text style={styles.headerText}>App Name</Text>
          </View>
          <View style={styles.loginInputs}>
            <Text style={styles.label}>Username</Text>
            <TextInput
              placeholder="Username"
              style={styles.input}
            />
            <Text style={styles.label}>Password</Text>
            <TextInput
              placeholder="Password"
              style={styles.input}
              secureTextEntry={true}
            />
            <TouchableOpacity style={styles.loginButton}>
              <Text style={styles.loginText}>Login</Text>
            </TouchableOpacity>
          </View>
      </KeyboardAwareScrollView>
    );
  }
}
[React Native] Prevent the On-screen Keyboard from Covering up Text Inputs的更多相关文章
- Apple & iOS & Device Screen Sizes and Orientations &  React Native
		
Apple & iOS & Device Screen Sizes and Orientations & React Native iOS devices https://de ...
 - React Native(ios)项目中logo,启动屏设置
		
由于logo和启动屏尺寸多,react native(ios)中没有命令可以自动生成各种的尺寸,所以可以使用以下办法:在ionic项目中生成(使用命令:ionic resources)后,再粘贴到re ...
 - React Native视频播放(iOS)
		
网站链接:http://www.ncloud.hk/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/learn-react-native-video/ React Nativ ...
 - 如何用 React Native 创建一个iOS APP?
		
诚然,React Native 结合了 Web 应用和 Native 应用的优势,可以使用 JavaScript 来开发 iOS 和 Android 原生应用.在 JavaScript 中用 Reac ...
 - React Native 之 项目实战(一)
		
前言 本文有配套视频,可以酌情观看. 文中内容因各人理解不同,可能会有所偏差,欢迎朋友们联系我. 文中所有内容仅供学习交流之用,不可用于商业用途,如因此引起的相关法律法规责任,与我无关. 如文中内容对 ...
 - React Native 系列(八) -- 导航
		
前言 本系列是基于React Native版本号0.44.3写的.我们都知道,一个App不可能只有一个不变的界面,而是通过多个界面间的跳转来呈现不同的内容.那么这篇文章将介绍RN中的导航. 导航 什么 ...
 - React Native 系列(九) -- Tab标签组件
		
前言 本系列是基于React Native版本号0.44.3写的.很多的App都使用了Tab标签组件,例如QQ,微信等等,就是切换不同的选项,显示不同的内容.那么这篇文章将介绍RN中的Tab标签组件. ...
 - React Native填坑之旅 -- 使用react-navigation代替Navigator
		
Navigator已经被React Native废弃了.也许你可以在另外的一个依赖库里react-native-deprecated-custom-components里找到.不过既然官方推荐的是re ...
 - React Native学习(三)—— 使用导航器Navigation跳转页面
		
本文基于React Native 0.52 参考文档https://reactnavigation.org/docs/navigators/navigation-prop 一.基础 1.三种类型 Ta ...
 
随机推荐
- HTML基础---表单
			
表单 <form id="" name="" method="post/get" action="负责处理的服务端" ...
 - [ TJOI 2007 ] 线段
			
\(\\\) \(Description\) 一个\(N\times N\) 的网格,每行有一段要必走,求从\((1,1)\)到\((N,N)\)的最短路长度. \(N\le 2\times10^4\ ...
 - NoSQL与关系数据库
			
关系型数据库:完全支持关系代数理论作为基础:有较大的数据规模:固定的数据库模式:查询效率快:强一致性:数据完整性较易实现:扩展性一般:可用性好. NoSQL:部分支持关系代数理论作为基础:有超大数据规 ...
 - Windows IIS 集成PHP时修改PHP.ini 配置后不生效问题
			
iis下修改c://windows/php.ini 重启iis的网站不生效.需要重启应用程序池即可生效.
 - Jmeter的面板介绍
			
一.jmeter面板介绍,这里是5.1.1版本 1.jmeter面板大致分为菜单区,图标区,目录树以及详细配置区域. 2.大多数人用着英文的面板不太舒服,可以在options里切换jmeter的语言 ...
 - CAD控件:QT开发使用控件入门
			
1. 环境搭建: 3 1.1. 安装Qt 3 1.2. 安装Microsoft Windows SDK的调试包 6 2. QT中使用MxDraw控件 7 1.3. 引入控件 7 3. 打开DWG文件 ...
 - 40条常见的移动端Web页面问题解决方案
			
1.安卓浏览器看背景图片,有些设备会模糊.想让图片在手机里显示更为清晰,必须使用2x的背景图来代替img标签(一般情况都是用2倍).例如一个div的宽高是100100,背景图必须得200200,然后b ...
 - P2041 分裂游戏
			
P2041 分裂游戏 手推$n=3$是无解的,推断$n>=3$是无解的 证明略,这是道结论题. #include<iostream> #include<cstdio> # ...
 - UVA - 820 Internet Bandwidth(最大流模板题)
			
题目: 思路: 直接套最大流的模板就OK了,注意一下输出的格式. 代码: #include <bits/stdc++.h> #define inf 0x3f3f3f3f #define M ...
 - Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)
			
题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...