1. 程式人生 > >React-native之flexDirection,justifyContent

React-native之flexDirection,justifyContent

1、flexDirection

佈局中子檢視排放的方向。有兩個值:水平軸(row),豎直軸(column)。預設是豎直軸。

flexDirection:'row'


flexDirection:'column'


'use strict';
import React,{Component} from 'react';
import {AppRegistry,View} from 'react-native';
class FixedDimensionsBasics extends Component{
    render(){
        return(
            <View style={{flex:1,flexDirection: 'row'}}>
                <View style={{width: 50,height: 50,backgroundColor: 'powderblue'}}></View>
                <View style={{width: 50, height: 50,backgroundColor: 'skyblue'}}></View>
                <View style={{width: 50, height: 50,backgroundColor: 'steelblue'}}></View>

            </View>
        );
    }
}
//MyFirstProject 必須初始化的專案名字
AppRegistry.registerComponent('MyFirstProject',() => FixedDimensionsBasics);

ps:powderblue、skyblue、steelblue 這些顏色值

參考:https://reactnative.cn/docs/0.42/colors.html#content

2、justifyContent

子元素沿著主軸的排列方式。有五個值:flex-start、center、flex-end、space-around以及space-between。預設是flex-start

flex-start:


center:


flex-end:


space-around:


space-between:


index.android.js:

'use strict';
import React,{Component} from 'react';
import {AppRegistry,View} from 'react-native';
class FixedDimensionsBasics extends Component{
    render(){
        return(
            <View style={{flex:1,flexDirection: 'column',justifyContent:'space-between'}}>
                <View style={{width: 50,height: 50,backgroundColor: 'powderblue'}}></View>
                <View style={{width: 50, height: 50,backgroundColor: 'skyblue'}}></View>
                <View style={{width: 50, height: 50,backgroundColor: 'steelblue'}}></View>

            </View>
        );
    }
}
//MyFirstProject 必須初始化的專案名字
AppRegistry.registerComponent('MyFirstProject',() => FixedDimensionsBasics);


相關推薦

React-nativeflexDirectionjustifyContent

1、flexDirection 佈局中子檢視排放的方向。有兩個值:水平軸(row),豎直軸(column)。預設是豎直軸。 flexDirection:'row' flexDirection:'column' 'use strict'; import React,{C

React NativeFlatListlistview的升級版

RN的0.43版終於出來了,現在大家期待已久的listview的升級版flatlist終於跟大家見面了,我也是關注了好久哦,現在將使用說明,和例子給大家簡單的講解下。http://www.jianshu.com/p/37f7a3d4f114 簡單的講解下api: fl

React native ES6語法(promise箭頭函式)

這裡總結幾個ES6與ES5區別中常用的幾塊。 一、箭頭函式 ES6中提供了使用(=>)符號來定義函式。 箭頭函式是用箭頭符號在需要回調函式的地方之間定義不需要名稱,程式碼簡潔。 將需要的引數放在=>前的()中即可,=>後就是函式體,

React Native Android混合開發及遇到的各種坑

最近自己也是剛在學習React Native的知識,在學習到React Native 嵌入到原生應用的時候,感覺遇到了各種坑,這裡做一下記錄。若有說得不對的地方,謝謝大家糾正。 React Native嵌入到原生應用的教程在其官方指導文件裡也有,但是感覺很多注意點沒講到,現

React Native彈框存在TextInput輸入框有焦點情況下需要點選兩次才可觸發事件-解決

Bug情況描述:React Native專案中,點選按鈕A出現彈框浮層,彈框中需要TextInput輸入數字,鍵盤浮起來;這時候點選 取消按鈕L 或者 確定按鈕R,只是讓鍵盤收起,但是並沒有觸發 取消

React Native使用“Debug JS Remote”時出現白屏跨域問題

啟用“Debug JS Remote”出現白屏,主要原因就是瀏覽器跨域限制,從而導致不能通過瀏覽器進行web除錯的目的。 解決方

react-native服務啟動運行項目到安卓模擬器

時間 輸入 nat bundle cmd 模擬器 項目 等待 模擬 1、在CMD中進入要啟動的項目下,輸入react-native start,等待啟動成功。成功之後再瀏覽器中訪問http://localhost:8081/index.android.bundle?plat

React NativeTouchable四組件

width font clas 容易 原生 ber 支持 cit out 一、TouchableHighlight 概念: 本組件用於封裝視圖,使其可以正確響應觸摸操作。當按下的時候,封裝的視圖的不透明度會降低,同時會有一個底層的顏色透過而被用戶看到,使得視圖變暗或變亮。

React Native登錄界面的布局

處理器 圖片 blank 轉載 圓角 print extends cit hit 版權聲明:本文為博主原創文章,未經博主允許不得轉載。 代碼註釋比較詳細 /** * Sample React Native App * https://github.com/fa

react-native遠程圖片修改後APP不更新

reactnative react-native react native 刷新圖片 base64今天在做客戶的項目時,有一個需求是App上要顯示遠端的圖片,而遠端的圖片有可能會更新,但圖片名不變。在react-native中,顯示圖片是用的自帶的Image組件,大家都知道react在更新組件之前都會判斷pr

使用WebStorm開發React-native基礎

ttr regexp 渲染 hang reg 路徑 tostring png text 配置問題: (1)找不到SDK路徑,或者沒有SDK對應的版本:SDK必須是android-23才可以(更新SDK) 解決方法:環境變量,必須設置Android_HOME

react-native模擬器調試

adb div connect oid native 令行 input 模擬 key 手動觸發搖一搖:adb shell input keyevent 82(有時模擬器搖一搖無效) android studio檢測不到模擬器: 命令行cd到模擬器安裝目錄,找到adb.exe

React Nativethis詳解

過程 show super try this registry alert item rop this引起的錯誤詳解 我們在學習React Native的過程中,肯定經常遇見過undefined is not an object這樣的問題吧,尤其是剛開始學習的

React Native屬性類型檢查機制詳解 PropType 變成 prop-types

word man div color object platform UC 靜態 ESS 屬性確認的作用 使用 React Native 創建的組件是可以復用的,所以我們開發的組件可能會給項目組其他同事使用。但別人可能對這個組件不熟悉,常常會忘記使用某些屬性,或者某些屬性傳

react nativelistview加下拉重新整理上拉分頁

直接上程式碼 var REQUEST_URL = 'xxxx&page='; import React, { Component } from 'react'; import { AppRegistry, Image, StyleSheet, Text, Vie

ios React-Native 找不到標頭檔案

我的解決辦法有點簡單暴力: 將package.json中的"react"直接改成16.2.0, react-native 改成了0.53.3,如下: "dependencies": {     "react": "16.2.0",     "re

React Native函式作為引數傳遞給另外一個函式去呼叫

1 用法 我們一般喜歡把js裡面的函式作為引數傳遞給另外一個函式,然後再呼叫這個函式,有點像C語言裡面的函式指標         2 程式碼測試 寫了一個函式,2個引數分別是函式,然後更具資料決定呼叫哪個函式 /** *

React Native通知欄訊息提示(android)

React Native之通知欄訊息提示(android)   一,需求分析與概述 1.1,推送作為手機應用的基本功能,是手機應用的重要部分,如果自己實現一套推送系統費時費力,所以大部分的應用都會選擇使用第三方的推送服務,如極光推送。 1.2,jpush-react-native 

React Native打包時報錯 java.lang.NullPointerException (no error message)

FAILURE: Build failed with an exception. what went wrong? java.lang.NullPointerException (no error message)   This Problem created when the

React Native通知欄訊息提示(ios)

React Native之通知欄訊息提示(ios)   一,需求分析與概述 詳情請檢視:React Native之通知欄訊息提示(android) 二,極光推送註冊與整合 2.1,註冊 詳情請檢視:React Native之通知欄訊息提示(android) 2.2,整合(ios) 第