Android SearchView - Move icon to right (without ActionBar)
I found a solution for this problem. Just set layout Direction to "rtl" and icon will be in Right Side. Here is the code for my search view and it is working as intended.
<SearchView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layoutDirection="rtl"
android:iconifiedByDefault="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
If the question is still unanswered:
Just move the SearchView into a RelativeLayout, and align it to the right side of the parent:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.SearchView
android:layout_width="wrap_content"
android:id="@+id/searchView"
android:layout_alignParentRight="true"
android:layout_height="match_parent" />
The final result looks like this:
CardView with Linearlayout containing aligned SearchView