• react native中DrawerLayoutAndroid组件示例与说明


    /**
    * 组件DrawerLayoutAndroid(安卓抽屉的实现)
      本篇DrawerLayoutAndroid属性和方法比较全一点
     * */

    import React,{PureComponent} from 'react'
    import {View,DrawerLayoutAndroid,Text,Dimensions,TextInput,TouchableOpacity} from 'react-native'
    class DrawerLayoutObj extends PureComponent {
    openDrawer=()=>{
    this.refs.drawerLayout.openDrawer()
    };
    closeDrawer=()=>{
    this.refs.drawerLayout.closeDrawer()
    };
    render() {
    var navigationView = (
    <View style={{flex: 1, backgroundColor: '#fff'}}>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    <Text style={{marginTop: 45, fontSize: 20, textAlign: 'center'}}>菜单列表</Text>
    </View>
    );
    return (
    <DrawerLayoutAndroid
    ref={'drawerLayout'}
    drawerLockMode='unlocked'
    drawerWidth={Dimensions.get('window').width-100}
    drawerPosition={DrawerLayoutAndroid.positions.Left}
    keyboardDismissMode="on-drag"
    onDrawerClose={()=>{}}
    onDrawerOpen={()=>{}}
    renderNavigationView={() => navigationView}
    rawerBackgroundColor="rgba(188,0,202,0.5)"
    statusBarBackgroundColor='red'
    >
    <View style={{flex: 1, alignItems: 'center'}}>
    <TouchableOpacity
    onPress={()=>this.openDrawer()}
    >
    <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>打开抽屉</Text>
    </TouchableOpacity>
    <TouchableOpacity
    onPress={()=>this.closeDrawer()}
    >
    <Text style={{margin: 10, fontSize: 15, textAlign: 'right'}}>关闭抽屉!</Text>
    </TouchableOpacity>
    <TextInput />
    </View>
    </DrawerLayoutAndroid>
    );
    }
    }
    export default DrawerLayoutObj;

    /***
    *
    drawerLockMode enum('unlocked', 'locked-closed', 'locked-open')

    设置抽屉的锁定模式。有三种状态:

    unlocked (默认值),意味着此时抽屉可以响应打开和关闭的手势操作。
    locked-closed,意味着此时抽屉将保持关闭,不可用手势打开。
    locked-open,意味着此时抽屉将保持打开,不可用手势关闭。
    无论抽屉处于那种状态,都仍然可以调用openDrawer/closeDrawer这两个方法打开和关闭。


    drawerPosition enum(DrawerConsts.DrawerPosition.Left, DrawerConsts.DrawerPosition.Right)

    指定抽屉可以从屏幕的哪一边滑入。

    drawerWidth number

    指定抽屉的宽度,也就是从屏幕边缘拖进的视图的宽度。

    keyboardDismissMode enum('none', "on-drag")

    指定在拖拽的过程中是否要隐藏软键盘。

    none (默认值),拖拽不会隐藏软键盘。

    on-drag 当拖拽开始的时候隐藏软键盘。

    onDrawerClose function

    每当导航视图(抽屉)被关闭之后调用此回调函数。

    onDrawerOpen function

    每当导航视图(抽屉)被打开之后调用此回调函数。

    onDrawerSlide function

    每当导航视图(抽屉)产生交互的时候调用此回调函数。

    onDrawerStateChanged function

    每当抽屉的状态变化时调用此回调函数。抽屉可以有3种状态:

    idle(空闲),表示现在导航条上没有任何正在进行的交互。

    dragging(拖拽中),表示用户正在与导航条进行交互。

    settling(停靠中),表示用户刚刚结束与导航条的交互,导航条正在结束打开或者关闭的动画。

    renderNavigationView function

    此方法用于渲染一个可以从屏幕一边拖入的导航视图。


    drawerBackgroundColor //这个属性貌似不起作用

    指定抽屉的背景颜色。
    默认值为白色。
    若要设置抽屉的不透明度,请使用rgba。

    statusBarBackgroundColor

    设置状态栏颜色(支持API21+/安卓系统5.0以上)

    此组件还提供openDrawer 与 closeDrawer

    openDrawer:打开抽屉
    closeDrawer:关闭抽屉
    ref={'drawerLayout'} //配套使用

    openDrawer(){
    this.refs.drawerLayout.openDrawer()
    }
    closeDrawer(){
    this.refs.drawerLayout.closeDrawer()
    }
    * ***/
  • 相关阅读:
    Struts2异常处理配置
    struts2支持的结果类型
    Project facet Java 1.8 is not supported by target runtime Apache Tomcat v7.0.
    net.paoding.analysis.exception.PaodingAnalysisException: dic home should not be a file, but a directory!
    struts.xml路径修改后的web配置
    struts.xml中的配置常量的含义
    Spring实战笔记
    2018第2周日
    新人替代旧人
    Web安全总结摘录
  • 原文地址:https://www.cnblogs.com/zhuyupingit/p/7644898.html
Copyright © 2020-2023  润新知