悬浮窗口的显示位置设置不生效的原因

来源:互联网 发布:数据分析专业排名 编辑:程序博客网 时间:2024/04/30 09:00

窗体的大小和位置通过WindowManager.LayoutParams来设置,在通过x和y值来设置窗体位置时,需要注意gravity属性,如果gravity没有设置或者是center之类的,那么设置的x和y值就不会起作用,具体的说明见
X position for this window. With the default gravity it is ignored. When using LEFT or START or RIGHT or END it provides an offset from the given edge.

Y position for this window. With the default gravity it is ignored. When using TOP or BOTTOM it provides an offset from the given edge.

0 0
原创粉丝点击