弹出菜单/弹层(Expand Layer)

Teamhelper Community2024-04-15 01:25:00

预览OVERVIEW

image-20240415021735585

基础用法

通过DataBinding创建

/**
 * DataBinding E.G
 */
GlassExpandPopup(mContext, instructManager).apply {
    contentWidth = 640
    direction = GlassExpandPopup.Companion.Direction.RIGHT
    val expandPopupBinding = DataBindingUtil.inflate<LayoutExpandPopupBinding>(
        LayoutInflater.from(mContext),
        R.layout.layout_expand_popup,
        null, false
    ).apply {
        btnTest.text = "测试按钮"
    }
    tipsText = "您可以通过“语音”或者“物理按键”进行选择"
    show<LayoutExpandPopupBinding>(R.layout.layout_expand_popup).let {
        it.btnTest.focus()
    }
}

设置宽度

GlassExpandPopup DSL {
  ...
  contentWidth = 640
  ...
}

设置高度

GlassExpandPopup DSL {
  ...
  contentHeight = 640
  ...
}

设置弹出方向

GlassExpandPopup DSL {
  ...
  direction = GlassExpandPopup.Companion.Direction.CENTER
  ...
}
enum class Direction {
    LEFT,
    RIGHT,
    CENTER,
    TOP,
    BOTTOM
}

设置提示文本

GlassExpandPopup DSL {
  ...
  tipsText = "您可以通过“语音”或者“物理按键”进行选择"
  ...
}

处理弹层View

GlassExpandPopup DSL {
  ...
     val expandPopupBinding = DataBindingUtil.inflate<LayoutExpandPopupBinding>(
                    LayoutInflater.from(mContext),
                    R.layout.layout_expand_popup,
                    null, false
                ).apply {
                    btnTest.text = "测试按钮"
                }
  ...
}

弹出弹层并设置操作焦点

GlassExpandPopup DSL {
  ...
                show<LayoutExpandPopupBinding>(R.layout.layout_expand_popup).let {
                    it.btnTest.focus()
                }
}
Last Updated 4/15/2024, 10:24:57 AM