최상욱
최상욱

Reputation: 11

(Android or AndroidTV) When we set setMeasuredDimension with (1,1), we got the black screen

I had some problem. When we set the setMeasuredDimension with (1,1), it makes blackscreen. (I'm looking for the behind view. But when we set (1,1) screen change to the black) In case I set the setMeasuredDimension with (2,2), it's operation has no problem. could you please tell the reason?

I trace callstack about that and I noticed that when the app is running to showing the customView2, nSetHasOverlappingRendering function at the RenderNode.java is called with true, and our tv set to black screen.

This is tested at the androidTV, and below is our build information. compileSdkVersion : 28 minSdkVersion : 28 targetSdkVersion : 28

Thanks for evenyone.

-- MainActivity --(This is for testing)

public class MainActivity extends Activity {
    testCustomView2 testCustomView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        testCustomView = new testCustomView2(getApplicationContext());

        WindowManager mWindowManager = (WindowManager)
            getApplication().getSystemService(Context.WINDOW_SERVICE);
        if (mWindowManager != null) {
            WindowManager.LayoutParams wmparams = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
                WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN,
                PixelFormat.OPAQUE);
            wmparams.gravity = Gravity.TOP | Gravity.START;
            mWindowManager.addView(testCustomView, wmparams);
        }
    }

}

--testCustomView2 (This is for testing)--


public class testCustomView2 extends View{
    Context mContext;
    public testCustomView2(Context context){
        super(context);
        mContext = context;
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        this.setMeasuredDimension(1, 1);
    }

}

-- activity_main.xml (res/layout)--

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/main_frame"
    android:background="@android:color/transparent"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

</FrameLayout>

Upvotes: 1

Views: 24

Answers (0)

Related Questions