container.vue 1.0 KB
Newer Older
lizhongyi_'s avatar
lizhongyi_ 已提交
1 2 3 4 5 6
<template>
	<view >
		<slot></slot>
	</view>
</template>
<script lang="uts">
7 8
  
  
lizhongyi_'s avatar
lizhongyi_ 已提交
9 10

	import LinearLayout from 'android.widget.LinearLayout'
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
  import Context from 'android.content.Context'
  import View from 'android.view.View'
  
  /**
   * 自定义android布局组件,可以实现监听显示状态等复杂的功能
   */
  class CustomLinearLayout extends LinearLayout{
    
      constructor(context: Context) {
        super(context)
      }
    
      override onWindowVisibilityChanged(visibility:kotlin.Int){
       
        if (visibility == View.VISIBLE){
          console.log("可见状态",visibility)
        }else if(visibility == INVISIBLE || visibility == GONE){
          console.log("不可见状态",visibility)
        }
      }
  }
  
lizhongyi_'s avatar
lizhongyi_ 已提交
33 34 35 36 37 38

	//原生提供以下属性或方法的实现  
	export default {
		name: "uts-hello-container",
		
		NVLoad(): LinearLayout {
39
			let contentLayout = new CustomLinearLayout($androidContext!)
lizhongyi_'s avatar
lizhongyi_ 已提交
40 41 42 43 44 45 46
			contentLayout.orientation = LinearLayout.VERTICAL;
			return contentLayout
		}
		
	}
</script>