React-Native需要css和布局-20160902
import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
} from 'react-native';
class helloworld extends Component {
  render() {
    return (
        <View style={styles.style_0}>
            <View style = {styles.styleView}>
                <Text style={styles.style_text}>自由摆放</Text>
            </View>
            <View style={[styles.styleView ,styles.centerView]}>
                    <Text style={styles.style_text}>居中显示</Text>
            </View>
            <View style={[styles.styleView,styles.rightView]}>
                    <Text style={styles.style_text}>居右显示</Text>
            </View>
            <View style={[styles.styleView,styles.leftView]}>
                <Text style={styles.style_text}>居左显示</Text>
            </View>
           <View style={[styles.styleView,styles.autoView,{marginTop:20}]}>
                 <Text style={styles.style_text}>自动显示</Text>
           </View>
           <View style={[styles.styleView,styles.stretchView,{marginTop:20}]}>
                 <Text style={styles.style_text}>伸展显示</Text>
             </View>
          <View style={styles.vertical_centerView}>
                 <Text style={styles.style_text}>垂直居中显示显示</Text>
          </View>
        </View>
    );
  }
}
        const styles = StyleSheet.create({
            style_0:{
                flex:1,
                borderColor:'red',
                borderWidth:2,
            },
            styleView:{
                width:100,
                height:50,
                backgroundColor:'blue'
            },
            style_text:{
                color:'white',
                marginTop:18,
                textAlign:'center',
            },
            centerView:{
              alignSelf:'center',
            },
            rightView:{
                alignSelf:'flex-end',
            },
            leftView:{
                alignSelf:'flex-start'
            },
            autoView:{
                alignSelf:'auto'
            },
            stretchView:{
                alignSelf:'stretch'
            },
            vertical_centerView:{
                flex:1,
                borderColor:'red',
                borderWidth:2,
                justifyContent:'center',
                alignItems:'center',
            },
        });
AppRegistry.registerComponent('小棚', () => helloworld);
运行结果

React-Native需要css和布局-20160902的更多相关文章
- React Native 中 CSS 的使用
		
首先声明,此文原作者为黎 跃春 React Native中CSS 内联样式 对象样式 使用Stylesheet.Create 样式拼接 导出样式对象 下面的代码是index.ios.js中的代码: / ...
 - 3、手把手教React Native实战之flexbox布局
		
flexbox是Flexible Box的缩写,弹性盒子布局 主流的浏览器都支持 flexbox布局是伸缩容器(container)和伸缩项目(item)组成 Flexbox布局的主体思想是元素可以 ...
 - 4、手把手教React Native实战之flexbox布局(伸缩属性)
		
###伸缩项目的属性 1.order 定义项目的排列顺序,数值越小,排列越靠前,默认值为0,语法为:order:整数值 2.flex-grow 定义伸缩项目的放大比例,默认值为0,即表示如果存在剩余空 ...
 - React Native入门  认识Flexbox布局
		
Flexbox布局是由W3C在09年提出的在Web端取代CSS盒子模型的一种布局方式. ReactNative实现了Flexbox布局的大部分功能. Flexbox布局所使用的属性,基本可以分为两大类 ...
 - React Native的ListView的布局使用
		
1> ListView组件用于显示一个垂直的滚动列表,其中的元素之间结构近似而仅数据不同. ListView更适于长列表数据,且元素个数可以增删.和ScrollView不同的是,ListView ...
 - 从web移动端布局到react native布局
		
在web移动端通常会有这样的需求,实现上中下三栏布局(上下导航栏位置固定,中间部分内容超出可滚动),如下图所示: 实现方法如下: HTML结构: <div class='container'&g ...
 - React Native基础&入门教程:初步使用Flexbox布局
		
在上篇中,笔者分享了部分安装并调试React Native应用过程里的一点经验,如果还没有看过的同学请点击<React Native基础&入门教程:调试React Native应用的一小 ...
 - React Native布局
		
一款好的APP离不了一个漂亮的布局,本文章将向大家分享React Native中的布局方式FlexBox. 在React Native中布局采用的是FleBox(弹性框)进行布局. FlexBox提供 ...
 - React Native探索(四)Flexbox布局详解
		
相关文章 React Native探索系列 前言 在Android开发中我们有很多种布局,比如LinearLayout和RelativeLayout,同样在React Native也有它的布局,这个布 ...
 
随机推荐
- VS2013 密钥 – 所有版本
			
Visual Studio Ultimate 2013 KEY(密钥):BWG7X-J98B3-W34RT-33B3R-JVYW9 Visual Studio Premium 2013 KEY(密钥) ...
 - vue.js 使用小结
			
2016年12月10日 17:18:42 星期六 情景: 主要介绍 v-for 循环时对变量的处理方法 主要以table标签为例 1. 为 tr 标签动态添加属性 <tr v-for=" ...
 - selenium测试框架使用xml作为对象库
			
之前已经写过一篇: selenium测试框架篇,页面对象和元素对象的管理 上次使用的excel作为Locator对象管理,由于excel处理不够方便,有以下缺点: 不能实现分page 加载Locato ...
 - 【翻译】Fluent NHibernate介绍和入门指南
			
英文原文地址:https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started 翻译原文地址:http://www.cnblogs ...
 - yii框架安装
			
YII安装: 下载最版本http://www.framework.com 下载高级的->yii with advanced APPlication template 解压至访问目录下 ...
 - Ubuntu 12.04 安装 Apache2+PHP5+MySQL
			
LAMP是Linux web服务器组合套装的缩写,分别是Apache+MySQL+PHP.此教程教大家如何在Ubuntu 12.04 LTS server 上安装Apache2服务器,包括PHP5(m ...
 - 悬浮TabBar的实现--此段代码来自网络
			
悬浮TabBar的实现 这个TabBar看着像是用自定义TabBar做的,但事实上它还是用的系统的TabBar,给系统的tabBar.backgroundImage设置一张设计好的背景图片. TabB ...
 - mysql 创建用户、授权等操作
			
一, 创建用户: 命令:CREATE USER 'username'@'host' IDENTIFIED BY 'password'; 说明:username - 你将创建的用户名, host - 指 ...
 - C/C++调试工具gdb
			
关于Gdb的使用,请参考:http://blog.csdn.net/haoel/article/details/2879
 - Ubuntu下安装JDK以及相关配置
			
1.查看系统位数,输入以下命令即可 getconf LONG_BIT 2.下载对应的JDK文件,我这里下载的是jdk-8u60-linux-64.tar.gz 3.创建目录作为JDK的安装目录,这里选 ...