CoordinatorLayout returns null

Asked by At

I am unable to get value of CoordinatorLayout in my Activity. When i try to get value by findviewbyid() it return null.

XML:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/coordinatorLayoutLogin"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/login_bg">


    </android.support.design.widget.CoordinatorLayout>

Java:

private CoordinatorLayout coordinatorLayout;

protected void onCreate(Bundle savedInstanceState) {


        coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinatorLayoutLogin);
    }

I am unable to understand why it is not working. Help me out.

I am using Samsung Note 8 with Android 9(One UI) installed also tried it on Samsung S8 and the behavior is same.

0 Answers