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 667 forks source link

FloatingSearchView in the middle of the screen #117

Closed Komatoz closed 8 years ago

Komatoz commented 8 years ago

Hi!

I want to place FloatingSearchView in the middle of the screen properly (inside fragment, Relative Layout)

That - FloatingSearchView appears only at the top:

            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"

That - when focus, fading zone is only 60 dp, not full screen

        android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_centerVertical="true"

How to do that properly?

arimorty commented 8 years ago

Hi @Komatoz ,

As stated here, You need to set the height of the FloatingSearchView to match where you want the fade and/or suggestions to appear. The suggestions will not extend outside of the view's bound, you have to make sure it has the room it needs for the suggestions.

The library can be very flexible, but I see that some developers have trouble configuring it in various ways. Because of that, I want to start a new blog where I would show in a step-by-step fashion how to implement different configurations/scenarios. This will serve as a kind of documentation for people using or trying to use this library.

What do you think? Would you want your case to be the first one that I will write how to implement?

If you do, please provide me with enough details of what you want to achieve so that I can write an example that you and others will benefit from. To be clear, I am not asking for any detailed info about what you are building, I just need a clear understanding of what you want to achieve.

Komatoz commented 8 years ago

Thank you for answer!

What do you think? Would you want your case to be the first one that I will write how to implement?

It would be nice!

I want to make something like this device-2016-08-16-122901

And this when FloatingSearchView is in focus device-2016-08-16-123048

arimorty commented 8 years ago

Hi @Komatoz , here is the blog post explaining how to achieve what you need. https://arimorty.github.io/tags/#floating-search-view

I hope it helps and others.

Komatoz commented 8 years ago

Thank you for your post!

But i didn't understand where I should place methods onFocus() and onFocusCleared(). Could you help me?

arimorty commented 8 years ago

You're welcome!

The sample app contains the source code for the example in the post. More specifically, look at this https://github.com/arimorty/floatingsearchview/blob/master/sample/src/main/java/com/arlib/floatingsearchviewdemo/fragment/SlidingSearchViewExampleFragment.java#L138

Komatoz commented 8 years ago

I implemented your hack, thank you so much!

Is it possible to use not fixing value for header_view and android:translationY? For example to place the Search View right in the middle of any screens?