zoukankan      html  css  js  c++  java
  • React-Native学习(一)

    一、Text 相当于安卓中的TextView或者OC中的Label,专门用来显示基本的文本信息;除了基本的显示布局之外,可以进行嵌套显示,设置样式,以及可以做事件(例如:点击)处理;
     
    二、Text组件常用的属性方法
    Attributes.style = {
        color string
        containerBackgroundColor string
        fontFamily string
        fontSize number
        fontStyle enum('normal', 'italic')
        fontWeight enum("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')
        lineHeight number
        textAlign enum("auto", 'left', 'right', 'center')
        writingDirection enum("auto", 'ltr', 'rtl')
    numberOfLines number
    textAlign (
    "auto", 'left', 'right', 'center', 'justify')
    fontWeight (
    "normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900') onPress fcuntion
    }

    注释如下:

    `color` 字体颜色

     `numberOfLines` (number) 进行设置Text显示文本的行数,如果显示的内容超过了行数,默认其他多余的信息就不会显示了

    `onPress` (fcuntion)  该方法当文本发生点击的时候调用该方法

     `color`  字体颜色

    `fontFamily`  字体名称

    `fontSize`  字体大小

    `fontStyle`   字体风格(normal,italic)

    `fontWeight ` 字体粗细权重("normal", 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900')

    `textShadowOffset`  设置阴影效果{ number, height: number}

    `textShadowRadius`  阴影效果圆角

    `textShadowColor`  阴影效果的颜色

    `letterSpacing`  字符间距

    `lineHeight`  行高

    `textAlign`   文本对其方式("auto", 'left', 'right', 'center', 'justify')

    `textDecorationLine`  横线位置 ("none", 'underline', 'line-through', 'underline line-through')

    `textDecorationStyle` 线的风格("solid", 'double', 'dotted', 'dashed')

     `textDecorationColor` 线的颜色

    `writingDirection` 文本方向("auto", 'ltr', 'rtf')

    三、Text组件中常用的属性的应用

    <Text style={styles.wl_textStyle} numberOfLines={5}>
    我是一段有个性的文字, haahahh,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
    </Text>

    wl_textStyle: {
    backgroundColor: 'red', // 背景色
    color: 'yellow', // 字体颜色
    textAlign: 'right',
    200,
    lineHeight: 30,
    fontSize: 18,
    fontWeight: 'bold',
    letterSpacing:5, // 字符间距
    textDecorationLine: 'underline', // 横线位置 ("none", 'underline', 'line-through', 'underline line-through')
    textDecorationStyle: 'double', // 线的风格("solid", 'double', 'dotted', 'dashed')
    textDecorationColor: 'black' // 线的颜色
    }
    
    
    四、Text组件中样式的继承
    在React-native中是没有样式继承这种说法的, 但是对于Text元素里边的Text元素,其实是能够继承的,那么是单层继承还是多层继承?
    <Text style={{color: 'yellow', fontSize: 11}}>
    <Text>
    <Text style={styles.wl_textStyle} numberOfLines={5}>
    我是一段有个性的文字, haahahh,哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈
    </Text>
    </Text>

    </Text>
    
    
    
    
    
  • 相关阅读:
    当td中文字过长时,显示为省略号
    清除页面缓存
    在dwr的调用类里获取请求信息
    解决利用hibernate连接mysql时无法插入汉字的问题
    MySql的数据库方言问题
    解决IE升级后必须以管理员运行的问题
    form表单里的button调用js函数
    EF多租户实例:演变为读写分离
    EF多租户实例:快速实现分库分表
    EF多租户实例:如何快速实现和同时支持多个DbContext
  • 原文地址:https://www.cnblogs.com/10-19-92/p/6479774.html
Copyright © 2011-2022 走看看