Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set a rightIcon for a search suggestion item? I only found leftIcon #257

Closed
AnotherJack opened this issue Jul 11, 2017 · 2 comments
Closed

Comments

@AnotherJack
Copy link

No description provided.

@joxad
Copy link

joxad commented Nov 9, 2017

you can create in your project layout an new item that is called the same name that the one used in the libs. THis way, it will override the layout provided by your implementation.

example for me : search_suggestion_item.xml

`

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

    <ImageView
        android:id="@+id/left_icon"
        android:layout_width="@dimen/square_button_size"
        android:layout_height="@dimen/square_button_size"
        android:layout_gravity="center"
        android:layout_marginStart="@dimen/search_bar_left_icon_left_margin"
        android:alpha="1"
        android:padding="@dimen/square_button_padding"
        android:visibility="gone" />


    <TextView
        android:id="@+id/body"
        style="@style/TextViewGreyLightNormal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="@dimen/margin_half_medium"
        android:contentDescription=""
        android:drawableEnd="@drawable/ic_chevron_right_grey_extra_light_24dp"
        android:gravity="center_vertical"
        android:paddingStart="@dimen/margin_medium"
        tools:text="search content" />


    <ImageView
        android:id="@+id/right_icon"
        android:layout_width="@dimen/square_button_size"
        android:layout_height="@dimen/square_button_size"
        android:layout_gravity="center"
        android:layout_marginEnd="@dimen/search_bar_right_icon_right_margin"
        android:alpha="1"
        android:background="@drawable/oval_btn_selector"
        android:padding="@dimen/square_button_padding"
        android:rotation="45"
        android:src="@drawable/ic_arrow_back_black_24dp"
        android:visibility="gone" />


</LinearLayout>


<View
    android:id="@+id/view"
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="@color/colorGrey" />
`

@akdotio
Copy link

akdotio commented May 21, 2019

Don't reinvent the wheel

SearchSuggestionsAdapter.OnBindSuggestionCallback { view, leftIcon, textView, item, _ ->
  val rightIcon = view?.findViewById<ImageView>(R.id.right_icon) // you have access to it here...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants