React-Native 一个简单的头部组件

功能要求:
创建一个二级头,头部标题居中显示,最右侧有个退出按钮。

import React, { Component } from 'react';
import {
    AppRegistry,
    Dimensions,
    StyleSheet,
    View,
    Text,
    Button,
} from 'react-native';
let ScreenWidth = Dimensions.get('window').width;
let ScreenHeight = Dimensions.get('window').height;
class TopScreen extends React.Component{
    render(){
        return(
            <View style={styles.secHeader}>
                <View style={styles.secTitle}>
                    <Text style={styles.secTitleText}>个人中心</Text>
                </View>
                <View style={styles.secLogout}>
                  <Text style={styles.secLogoutText}>注销</Text>
                </View>
            </View>
        );
    }
}

const styles=StyleSheet.create({
   secHeader:{
      backgroundColor:"#f1f1f1",
      borderBottomWidth:1,
      borderBottomColor:"#ddd",
   },
   secTitle:{
      height:50,
      flexDirection: 'row',
      justifyContent: 'center',
      alignItems: 'center',
   },
   secTitleText:{
      fontSize:18,
      fontWeight:'600',
   },
   secLogout:{
      height:50,
      width:ScreenWidth-10,
      flexDirection: 'row',
      justifyContent: 'flex-end',
      alignItems: 'center',
      position: 'absolute',
   },

});

module.exports=TopScreen;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 174,081评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,269评论 4 61
  • 昨天,《花花公子》的创始人休·海夫纳去世了,享年91岁。如果你不知道这个老头儿,那可以说是非常纯洁了! 作为一个色...
    装装子阅读 959评论 0 1
  • 材料:泡菜坛子,白酒52度左右,冰糖,盐。大白菜,白萝卜,红萝卜,生姜,辣椒等看自己口味。 步骤:一,洗干净所有用...
    开心百合阅读 449评论 0 0
  • 2017.8.6 星期日 昨天提前和陶陶商量好了今天的日程,早上八点起床,九点弹琴半小时然后去做蛋糕。 结果就是,...
    梁师一友阅读 203评论 0 3