如何在锁定屏幕上显示 SurfaceView? [英] How to show SurfaceView on Lock Screen?

查看:55
本文介绍了如何在锁定屏幕上显示 SurfaceView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力实现一个锁屏,就像三星 Galaxy 3 的水波纹锁屏一样.我已经完成了 GLSurfaceView 对象.但是当我将它移植到锁定屏幕时出现问题.SurfaceView 无法在窗口类型为 TYPE_KEYGUARD 的锁定屏幕上显示.如果我对这个 SurfaceView 使用 setZOrderOnTop(true) ,它可以显示,但它会覆盖锁定屏幕的所有其他层,这不是我的预期.这个SurfaceView可以在正常的应用中正常显示.我使用adb shell dumpsys SurfaceFlinger"来转储层信息.它的visibleRegionScreen就是这样,区域可见区域屏幕(this=0x15841a0,count=1)[ 0, 0, 0, 0]

I'm working to implement a lock screen just like the water ripple lock screen of Samsung Galaxy 3. I have finished the GLSurfaceView object. But there is a problem when I port it to Lock Screen. The SurfaceView couldn't be displayed on Lock Screen whose window type is TYPE_KEYGUARD. If I use setZOrderOnTop(true) to this SurfaceView, it Can be displayed, but it will overlay all other layers of Lock Screen, which is not my anticipation. This SurfaceView can display normally on normal application. I used "adb shell dumpsys SurfaceFlinger" to dump the layers information. Its visibleRegionScreen is just as this, Region visibleRegionScreen (this=0x15841a0, count=1) [ 0, 0, 0, 0]

有人知道如何解决此问题并在锁定屏幕上显示 SurfaceView 吗?非常感谢.

Anyone kown how to resolve this issue and display a SurfaceView on Lock Screen? Thanks a lot.

推荐答案

感谢您的评论.附上我的实现供您参考.GLSurfaceView 无法在锁定屏幕上显示.我的布局是这样的:

I'm appreciate for your comment. Attach my implemention for your referrence. The GLSurfaceView couldn't be shown on Lock screen. My Layout is as this:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/my_lockscreen_root"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

<FrameLayout
    android:id="@+id/my_lockscreen_clock"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" 
    android:visibility="gone"/>

在 LockScreen.java 构造函数上添加 GLSurfaceViewn:

Add the GLSurfaceViewn on LockScreen.java constructor:

RelativeLayout mRootLayout = (RelativeLayout) findViewById(R.id.my_lockscreen_root);
View myGLSurfaceView = new MyGLSurfaceView(mContext, mCallback);
FrameLayout.LayoutParams layoutparams = 
   new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
mRootLayout.addView(mUnlockWidget, 0, layoutparams);

这篇关于如何在锁定屏幕上显示 SurfaceView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆