'How to use SearchView with fragment

I am using a RecyclerView and on the top of the RecyclerView I am using a SearchView but the SearchView is not focusable. I have tried with EditText too, but the EditText is also not focusable.
Can't we use EditText or Search View with Recyclerview in Fragment?
Here is my XML code

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:padding="3dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="3dp"
            android:gravity="left"
            android:text="Stocks"
            android:textColor="@color/black"
            android:textSize="20sp"
            android:textStyle="bold" />

        <EditText                             // here I have tried with SearchView 
            android:id="@+id/search"
            android:layout_width="match_parent"
            android:layout_height="40dp"
            android:layout_gravity="center"
            android:paddingLeft="15dp"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center_vertical|left"
            android:layout_marginHorizontal="4dp"
            android:background="@drawable/search_border"
            android:hint="Search Stocks" />
    </LinearLayout>

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/recyclerViewStock"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source