So I have a ListView in which I have filled random values. I also have a SearchView above the ListView. Whenever I click the SearchView, the Listview goes up. I do not want the Listview to be moved from its place. I am attaching two images for reference.
This is when the searchview is not active
This is when the searchview is active
Edit:: On emulator it works fine
CODE::`
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<ImageView
android:id="@+id/NavigationBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="17dp"
android:adjustViewBounds="true"
android:padding="7dp"
android:src="@drawable/navigation_bar" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="65dp"
android:layout_marginLeft="65dp"
android:layout_marginTop="17dp"
android:fontFamily="@font/product_sans_bold"
android:text="Library"
android:textColor="@color/green"
android:textSize="39sp" />
<ListView
android:id="@+id/ListView"
android:layout_width="match_parent"
android:layout_height="649dp"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:layout_centerInParent="true"
android:layout_marginStart="0dp"
android:layout_marginBottom="0dp"
android:divider="@null" />
<androidx.appcompat.widget.SearchView
android:layout_width="362dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="76dp"
android:background="@drawable/search_background"
app:iconifiedByDefault="false"
app:queryBackground="@android:color/transparent"
app:queryHint="Search music"
app:searchHintIcon="@null"
app:searchIcon="@drawable/search" />
</RelativeLayout>
` NOTE: I HAVE A CUSTOM LISTVIEW IN WHICH I AM FILLING VALUES. I HAVE NOT IMPLEMENTED SEARCHVIEW CODE TILL NOW.
Advertisement
Answer
Adding these lines of code solved the problem.
Hope this may help some coder.
android:focusableInTouchMode="false" android:isScrollContainer="false"

