当前位置: 首页 > news >正文

网页设计论文致谢北京网站优化经理

网页设计论文致谢,北京网站优化经理,网页程序开发学什么语言,nodejs php wordpress在 React Native 中要实现可触摸的组件方式有三种,第一种方式就是使用TouchableHighlight组件,第二种方式就是使用TouchableOpacity组件,最后一种方式就是使用TouchableWithoutFeedback组件。 TouchableHighlight TouchableHighlight组件主…

在 React Native 中要实现可触摸的组件方式有三种,第一种方式就是使用TouchableHighlight组件,第二种方式就是使用TouchableOpacity组件,最后一种方式就是使用TouchableWithoutFeedback组件。

TouchableHighlight

TouchableHighlight组件主要是响应触摸的组件。当用户按下此组件时,此组件的亮度会变成高亮显示(由透明改为不透明),从而让用户感知到进行了交互。TouchableHighlight假如不设置underlayColor属性的话,underlayColor 的默认值为黑色。假如此组件的子元素也有样式的话,可能会发生颜色重叠导致一些问题。

TouchableHighlight组件必须有一个子级(不能为零个或多个)。如果您希望有多个子组件,请将它们包装在视图中。具体实例如下:

import { StyleSheet, Text, TouchableHighlight, View } from "react-native";
import React, { useState } from "react";export default function TouchComponent() {const [count, setCount] = useState<number>(0);return (<View style={styles.container}><Text style={styles.mainTitle}>触摸组件实例</Text><TouchableHighlightactiveOpacity={0.4}underlayColor="#DDDDDD"onPress={() => setCount(count + 1)}><View style={styles.button}><Text>点击加1</Text></View></TouchableHighlight><Text>{count}</Text></View>);
}const styles = StyleSheet.create({container: {margin: 8,},mainTitle: {fontSize: 22,fontWeight: "bold",padding: 10,borderBottomWidth: 1,borderColor: "#e3e3e3",},button: {alignItems: "center",backgroundColor: "#DDDDDD",padding: 10,},
});

TouchableOpacity

TouchableOpacity组件跟TouchableHighlight的作用一致,此组件的透明度会发生改变(由不透明改为透明),从而能让用户感知到进行了交互。假如此组件的子元素也有样式的话,可能会发生颜色重叠导致一些问题。

通过将子组件包装在 Animated.View 中(添加到视图层次结构中)来控制不透明度。请注意,这可能会影响布局。具体的实例如下:

import {StyleSheet,Text,TouchableHighlight,TouchableOpacity,View,
} from "react-native";
import React, { useState } from "react";export default function TouchComponent() {const [count, setCount] = useState<number>(0);return (<View style={styles.container}><Text style={styles.mainTitle}>触摸组件实例</Text><TouchableOpacity onPress={() => setCount(count + 1)}><Text style={styles.button}>点击加1</Text></TouchableOpacity><Text>{count}</Text></View>);
}const styles = StyleSheet.create({container: {margin: 8,},mainTitle: {fontSize: 22,fontWeight: "bold",padding: 10,borderBottomWidth: 1,borderColor: "#e3e3e3",},button: {alignItems: "center",backgroundColor: "#DDDDDD",padding: 10,},
});

TouchableWithoutFeedback

TouchableWithoutFeedback此组件是不会发生任何视觉反馈信息的。TouchableWithoutFeedback 仅支持一个孩子。如果您希望有多个子组件,请将它们包装在视图中。重要的是,TouchableWithoutFeedback 的工作原理是克隆其子级并向其应用响应者道具。因此,任何中间组件都需要通过这些 props 传递给底层的 React Native 组件。

import {StyleSheet,Text,TouchableHighlight,TouchableOpacity,TouchableWithoutFeedback,View,
} from "react-native";
import React, { useState } from "react";export default function TouchComponent() {const [count, setCount] = useState<number>(0);return (<View style={styles.container}><Text style={styles.mainTitle}>触摸组件实例</Text><TouchableWithoutFeedback onPress={() => setCount(count + 1)}><View style={styles.button}><Text>点击加1</Text></View></TouchableWithoutFeedback><Text>{count}</Text></View>);
}const styles = StyleSheet.create({container: {margin: 8,},mainTitle: {fontSize: 22,fontWeight: "bold",padding: 10,borderBottomWidth: 1,borderColor: "#e3e3e3",},button: {alignItems: "center",backgroundColor: "#DDDDDD",padding: 10,},
});
http://www.ritt.cn/news/19344.html

相关文章:

  • 做淘宝需要的网站焊工培训ppt课件
  • 东莞网站关键词推广搜索引擎优化seo优惠
  • 网站建设原则代运营公司是怎么运营的
  • 兰州西固区公司网站建设提高工作效率的句子
  • 太原市城乡建设局网站含有友情链接的网页
  • 企业网站建设需要提供什么内容百度外推排名
  • 商业网站开发岗位需求分析网站推广优化c重庆
  • wordpress SEO模广东宣布即时优化调整
  • 培训网站建设情况网站搭建软件
  • 网站建设的杂志网站域名查询ip
  • ps个人网站手机域名访问网站怎么进入
  • 做装饰工程的在什么网站投标游戏推广可以做吗
  • 山东食品行业网站模板推广放单平台
  • 做网站选哪个语言网络推广员是什么工作
  • 免费建设个人手机网站百度热议怎么上首页
  • 石材网站建设百度推广优化怎么做的
  • c 手机网站开发模板长春刚刚最新消息今天
  • 蓝色网站风格推广链接怎么自己搞定
  • 深圳网站开发深圳网页设计公司
  • 怎样做网站备案网站制作公司有哪些
  • 郑州商城网站开发深圳关键词推广
  • 深圳做网站排名公司班级优化大师官网下载
  • 网站开发步骤 java厦门人才网个人会员登录
  • 有了网站源码可以做网站吗百度爱采购平台登录
  • 长宁武汉阳网站建设站长工具网址查询
  • html+jsp个人网站模板如何开网站呢
  • 一 网站开发体会推广方式和推广渠道
  • 公司网站建设包括哪些东西长沙网站推广智投未来
  • 做网站月薪10万关键词智能优化排名
  • 网站运营需要服务器吗怎么创建网站教程