Handling Touches - RN3
1. basic button
format:
<tag event caption />
<Button
onPress={{}}
title="I am button"
/>
<Button
onPress={() => {
Alert.alert("You are Right!");
}}
title="Push me"
/>
Usage:
(1) import
import {Button, Alert} from "react-native";
(2) src
import React from 'react';
import { StyleSheet, Text, View, Button, Alert } from 'react-native'; export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Button
onPress={() => {
Alert.alert("You are Right!");
}}
title="Push me"
/>
</View>
);
}
} const styles = StyleSheet.create({
container: {
flex: ,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
2. Actual button
format:
<tag event caption />
<TouchableHighlight event>
<View>
<Text>caption</Text>
</View>
</TouchableHighlight>
for example:
<TouchableHighlight onPress={this._onPressButton} underlayColor="white">
<View style={styles.button}>
<Text style={styles.buttonText}>I am a rounded button</Text>
</View>
</TouchableHighlight>
Usage:
(1) import
import {Platform, TouchableHightlight} from "react-native"
(2) src
import React from 'react';
import { StyleSheet, Text, View, Platform, TouchableHighlight, Alert } from 'react-native'; export default class App extends React.Component {
_onPressButton() {
Alert.alert('You tapped the button!')
} render() {
return (
<View style={styles.container}>
<TouchableHighlight onPress={this._onPressButton} underlayColor="white">
<View style={styles.button}>
<Text style={styles.buttonText}>I am a rounded button</Text>
</View>
</TouchableHighlight>
</View>
);
}
} const styles = StyleSheet.create({
container: {
paddingTop: ,
alignItems: 'center'
},
button: {
marginBottom: ,
width: ,
alignItems: 'center',
backgroundColor: '#2196F3',
borderRadius:
},
buttonText: {
padding: ,
color: 'white'
}
});
Reference:
1. Handling Touches - Displaying a basic button
2. Handling Touches - Touchables
Handling Touches - RN3的更多相关文章
- Event Handling Guide for iOS--(一)--About Events in iOS
About Events in iOS Users manipulate their iOS devices in a number of ways, such as touching the scr ...
- UIImageWriteToSavedPhotosAlbum
UIImageWriteToSavedPhotosAlbum: Next UIKit Function Reference Overview The UIKit framework defines a ...
- 【IOS笔记】About Events in iOS
About Events in iOS Users manipulate their iOS devices in a number of ways, such as touching the scr ...
- iOS苹果官方Demo合集
Mirror of Apple’s iOS samples This repository mirrors Apple’s iOS samples. Name Topic Framework Desc ...
- Event Handling Guide for iOS--(三)---Event Delivery: The Responder Chain
Event Delivery: The Responder Chain 事件传递:响应链 When you design your app, it’s likely that you want to ...
- Event Handling Guide for iOS--(二)---Gesture Recognizers
Gesture Recognizers 手势识别器 Gesture recognizers convert low-level event handling code into higher-leve ...
- 移动端事件对象touches的误区
不想长篇大论,也是自己遗留下的一个错误的理解 在移动端触屏事件有四个 // 手势事件 touchstart //当手指接触屏幕时触发 touchmove //当已经接触屏幕的手指开始移动后触发 tou ...
- touch事件中的touches、targetTouches和changedTouches详解
touches: 当前屏幕上所有触摸点的列表; targetTouches: 当前对象上所有触摸点的列表; changedTouches: 涉及当前(引发)事件的触摸点的列表 通过一个例子来区分一下触 ...
- touches 事件捕获不到
在UIView上加载了一个UIScrollView(全屏),touches 事件捕获不到了 原因:UIView的touch事件被UIScrollView捕获了,无法传递下去 解决方法:写一个UIScr ...
随机推荐
- .net core部署到Ubuntu碰到的问题
数据库连接的时候,会报错“MySql.Data.MySqlClient.MySqlException:“The host localhost does not support SSL connecti ...
- Jumpserver跳板机的搭建和部署
1.需要搭云yum仓库wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo 2. ...
- neutron之neutron_openvswitch_agent占用100%CPU资源问题
基于kolla-ansible部署的queens版本,基于docker stats查看openstack的资源占用,发现neutron_openvswitch_agent一直占用100%CPU资源,这 ...
- firstPage
自己写的科比的一个简单介绍的网页,画面,布局还是太垃圾了,图片放大缩小标签不知道,简直难受. <!DOCTYPE html><html> <head> <me ...
- 北大poj- 1006
生理周期 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 133189 Accepted: 42577 Descripti ...
- python day18--面向对象,继承
# class Animal: # breath = '呼吸' # # def __init__(self, name, sex, age): # self.name = name # self.se ...
- VS Code + NWJS(Node-Webkit)0.14.7 + SQLite3 + Angular6 构建跨平台桌面应用
一.项目需求 最近公司有终端桌面系统需求,需要支持本地离线运行(本地数据为主,云端数据同步),同时支持Window XP,最好跨平台.要求安装配置简单(一次性打包安装),安装包要小,安装时间短,可离线 ...
- vue.js--遇到的一些错误
1. <sapn> - did you register the component correctly? For recursive components, make sure to p ...
- iOS tableView分割线高度自定义
1.系统自带的集中分割线的形式 myTableView.separatorStyle=UITableViewCellSeparatorStyleNone;(这个是去掉所有分割线)可以通过这个来设置 2 ...
- 软件工程 week 04
四则运算 一.摘要 作业地址:https://edu.cnblogs.com/campus/nenu/2016CS/homework/2266 git仓库地址:https://git.coding.n ...