arimorty / floatingsearchview

A search view that implements a floating search bar also known as persistent search
https://github.com/arimorty/floatingsearchview/blob/master/README.md
Apache License 2.0
3.54k stars 668 forks source link

Add an imageview instead of search hint #299

Open mladenbabic opened 6 years ago

vutrannguyen commented 3 years ago

@mladenbabic Have you solved this problem yet? Looking forward to sharing

mladenbabic commented 3 years ago

@vutrannguyen Yes, but it is too much customized for my project and it won't be helpful for you.

vutrannguyen commented 3 years ago
    Thanks for the reply @mladenbabic . I solved that problem like this:
        Toolbar headerMain = view.findViewById(R.id.headerMain);
        SearchInputView searchBar = headerMain.findViewById(R.id.search_bar_text);
        ImageView imageView = new ImageView(getContext());
        imageView.setImageResource(R.drawable.logo);

        FrameLayout frameLayout = headerMain.findViewById(R.id.search_input_parent);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                RelativeLayout.LayoutParams.WRAP_CONTENT,
                RelativeLayout.LayoutParams.WRAP_CONTENT
        );
        layoutParams.setMargins(-80,15,0,15);
        layoutParams.addRule(RelativeLayout.BELOW, R.id.search_input_parent);
        layoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);

        frameLayout.addView(imageView, layoutParams);