React Native基础组件

转载请注明出处:小楼一夜听春雨的专栏http://blog.csdn.net/win816723459/article/details/54134171

本节主要介绍以下组件

  • View 容器组件(同Html中的div标签)
  • Text 文本组件(同Html中的p标签)
  • Image 图片组件
  • TextInput 输入组件
  • ScrollView 滑动容器组件(同原生组件ScrollView滑动方向水平和垂直)

1.View 容器组件

  • 定义

    <View>React Native组件,相当于html中的<div>标签,具有相同的特性,支持嵌套。<View>组件可以把固定的区间分割成独立的、不同的部分。用于严格的模块化布局组织工具,默认内部child垂直排列,可调整排列方向,这点与Android原生组件LinearLayout很像。

  • 主要属性 (详细请参考View

    • pointerEvents enum(‘box-none’, ‘none’, ‘box-only’, ‘auto’)
    用于控制当前视图是否可以作为触控事件的目标。
    * auto: 视图可以作为触控事件的目标
    * none: 视图不能作为触控事件的目标
    * box-none: 视图自身不能作为触控事件的目标,但其子视图可以。
    * box-only:视图自身可以作为触控事件的目标,但其子视图不能。
    • 样式
    Flexbox
    
    backfaceVisibility enum('visible', 'hidden')
    
    backgroundColor string
    
    borderColor string
    
    borderTopColor string
    
    borderRightColor string
    
    borderBottomColor string
    
    borderLeftColor string
    
    borderRadius number
    
    borderTopLeftRadius number
    
    borderTopRightRadius number
    
    borderBottomLeftRadius number
    
    borderBottomRightRadius number
    
    borderStyle enum('solid', 'dotted', 'dashed')
    
    borderWidth number
    
    borderTopWidth number
    
    borderRightWidth number
    
    borderBottomWidth number
    
    borderLeftWidth number
    
    opacity number
    
    overflow enum('visible', 'hidden')
    
    android elevation number
    (限Android)使用Android原生的 elevation API来设置视图的高度(elevation)。这样可以为视图添加一个投影,并且会影响视图层叠的顺序。此属性仅支持Android5.0及以上版本。
  • 用法

    View用法与LinearLayout一致,唯一的区别在于自身可定制的属性不同,下面结合代码介绍,见注释:

/**
 * Created by liyanxi on 2016/11/28.
 */
import React, { Component } from 'react';
import {
    StyleSheet,
    Text,
    View
} from 'react-native';
export default class WelcomDemo <
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值