How to show SurfaceView on Lock Screen?

空扰寡人 提交于 2019-12-04 19:24:53

You are right about the setZOrderOnTop(true) call but I don't really understand your question. You are only seeing the SurfaceView throughout the whole screen? In that case, just place a LinearLayout in the lock screen layout xml and add your Surfaceview to that.

In keyguard_screen_tab_unlock.xml after the digital clock view, put:

<LinearLayout
        android:id="@+id/dummyGLLayout"
        android:orientation="vertical"
        android:layout_width="match_parent"
         android:layout_height="wrap_content"
        android:gravity="top">
</LinearLayout>

In LockScreen.java constructor:

GLSurfaceView mySurfaceView
mySurfaceView = new MySurfaceViewClass(mContext);
LinearLayout ll = (LinearLayout) findViewById(R.id.dummyGLLayout);
mySurfaceView.setZOrderOnTop(true);
ll.addView(mySurfaceView);

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"/>

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!