Search code examples
androidxmlandroid-layoutsearchview

SearchView cursor not visible


The cursor inside my searchview is not visible. how can i make it visible?

<androidx.appcompat.widget.SearchView
    android:id="@+id/edit_query"
    android:layout_width="0dp"
    android:layout_height="50dp"
    android:background="@android:color/white"
    android:ems="10"
    android:importantForAutofill="no"
    android:inputType="text"
    android:textColor="@color/app_dark_color"
    android:textStyle="bold"
    app:iconifiedByDefault="false"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:queryHint="@string/search"
    app:searchIcon="@drawable/ic_ricerca"
    tools:ignore="LabelFor"
    tools:text="Name" />

Solution

  • I reviewed your question and the same problem that we had encountered in the past. One of the solutions we have tried has resolved our problem. Please try with that solution it may solve your issue.

    <androidx.appcompat.widget.SearchView    
    android:id="@+id/edit_query"    
    android:layout_width="0dp"    
    android:layout_height="50dp"    
    android:background="@android:color/white"    
    android:ems="10"    
    android:importantForAutofill="no"    
    android:inputType="text"    
    android:textColor="#ff0000"    
    android:textStyle="bold"    
    app:iconifiedByDefault="false"    
    app:layout_constraintEnd_toEndOf="parent"    
    app:layout_constraintStart_toStartOf="parent"    
    app:layout_constraintTop_toTopOf="parent"
    app:queryHint="Search"
    tools:ignore="LabelFor"
    android:theme="@style/searchViewTheme"
    tools:text="Name" />
    

    style.xml

        <style name="searchViewTheme"parent="Theme.MaterialComponents.DayNight.DarkActionBar">
        <item name="colorControlActivated">@android:color/holo_orange_dark</item>
    </style>