Giter VIP home page Giter VIP logo

search-view-layout's Introduction

THIS PROJECT IS DEPRECATED

Component is not maintained anymore.

Implementation of Lollipop+ Dialer and Google Maps.

DEMO

Screenshot

Add in View

Add to your layout by using the include tag.

<include layout="@layout/widget_search_bar"/>

API

This overlays the full activity and shows the fragment which you have assigned by using setExpandedContentFragment.

searchViewLayout.setExpandedContentFragment(this, new SearchStaticFragment());

If you want to animate your Toolbar too like the demo gif, you can enable it by using handleToolbarAnimation.

searchViewLayout.handleToolbarAnimation(toolbar);

Setting Background colors for Transition. Default should also work just fine:

// Create Drawable for collapsed state. Default color is android.R.color.transparent
ColorDrawable collapsed = new ColorDrawable(
    ContextCompat.getColor(this, R.color.colorPrimary));

// Create Drawable for expanded state. Default color is #F0F0F0
ColorDrawable expanded = new ColorDrawable(
    ContextCompat.getColor(this, R.color.default_color_expanded));

// Send both colors to searchViewLayout
searchViewLayout.setTransitionDrawables(collapsed, expanded);

Listen to search complete by:

searchViewLayout.setSearchListener(new SearchViewLayout.SearchListener() {
    @Override
    public void onFinished(String searchKeyword) {
        searchViewLayout.collapse();
        Snackbar.make(searchViewLayout, "Search Done - " + searchKeyword, Snackbar.LENGTH_LONG).show();
    }
});

Listen to collapse/expand animation by using setOnToggleAnimationListener. For eg the FAB in demo hides on expanded and shows on collapse.

searchViewLayout.setOnToggleAnimationListener(new SearchViewLayout.OnToggleAnimationListener() {
    @Override
    public void onStart(boolean expanded) {
        if(expanded) {
            fab.hide();
        } else {
            fab.show();
        }
    }

    @Override
    public void onFinish(boolean expanded) { }
});

Listen to search box complete by:

searchViewLayout.setSearchBoxListener(new SearchViewLayout.SearchBoxListener() {
    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {
    }
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    }
    @Override
    public void afterTextChanged(Editable s) {
    }
});

Setting Hints

If you want to set hints in the view, there are three APIs. setCollapsedHint would come up in the default/collapsed state. setExpandedHint would work for expanded state i.e. after click the view and the keyboard is up. setHint would set both the hints in one go, use this you want to show the same hint in both the states.

searchViewLayout.setCollapsedHint("Collapsed Hint");
searchViewLayout.setExpandedHint("Expanded Hint");
searchViewLayout.setHint("Global Hint");

Setting Icons Use setCollapsedIcon, setExpandedBackIcon, setExpandedSearchIcon to setup icons according to your choice. The argument should be a DrawableRes

NOTES

  1. If you want to add a scrolling widget in your setExpandedContentFragment, add a onTouchListener and disallow the parent intercept by usingv.getParent().requestDisallowInterceptTouchEvent(true);Check out fragments in sample for the implement of ListView, RecyclerView and ScrollView.

    recyclerView.setOnTouchListener(new View.OnTouchListener() {
        // Setting on Touch Listener for handling the touch inside ScrollView
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // Disallow the touch request for parent scroll on touch of child view
            v.getParent().requestDisallowInterceptTouchEvent(true);
            return false;
        }
    });
  2. The default height of the view is 120dp which is also present in the dimens.xml file as

    <dimen name="search_view_layout_approx_height">120dp</dimen>

    You can use it for adding margin on top of your main content layout.

GET

Available at jCenter and mavenCentral.

dependencies {
    compile 'xyz.sahildave:searchviewlayout:0.6'
}

CHANGELOG

0.6

  • Added support for API 15

0.5

  • Added support for fragment-v4

0.4

  • Moved anim files to /animator res dir

0.3

  • Added search edit text API
  • Larger touch target

0.2

  • Added APIs for setting icons
  • Improved animations by using onAnimationUpdate

0.1

  • Added hints API.
  • Added search_view_layout_approx_height

0.0.2

  • Added API setTransitionDrawables which solves crashes in < API 19

Contribute

Contribute by creating issues (tagged enhancement, bugs) in the repo or create a pull request.

search-view-layout's People

Contributors

ajans avatar balazsgerlei avatar johnjohndoe avatar sahildave avatar tfmend avatar tim-bm avatar vguzzi avatar ysy950803 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

search-view-layout's Issues

minSdkVersion 15 cannot be smaller than version 16 declared in library

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be smaller than version 16 declared in library [xyz.sahildave:searchviewlayout:0.5] /home/User/Example/WORKSPASE/NewProject/app/build/intermediates/exploded-aar/xyz.sahildave/searchviewlayout/0.5/AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="xyz.sahildave.widget" to force usage

Too small touch target for the back arrow

While I like the design and behaviour of this lib a lot, there is a small, but important hurdle with it: when the search layout is expanded, the back arrow displayed on the left side has a way too small touch target. I think the best would be as high as the whole search layout, and the same width too (so it retains the 1:1 ratio).

Now it's barely bigger than the arrow itself and really easy to miss. Please correct it, it would improve the usability a lot!

Support v4 fragment

I'm trying to launch a support.v4.fragment, but I get Wrong 2nd type argument, how can I solve this?

GPL License

I am evaluating the use of your Search-View-Layout library in our closed-source app.
Unfortunately, the LICENSE-file in the root-folder specifies the usage of your library according to the GPL-2.0 license, which demands full source code disclosure even for the apps using your library.

As it is not an option for me to disclose the apps' source code, I would like to propose a license-change to

http://www.apache.org/licenses/LICENSE-2.0

in order to enable developers of commercial apps to use your great library.

If you want, I could create a pull request with the license-change from my forked repository.

Slow

Very very slow

layout confusion

Quick click, resulting in animation cancellation, layout confusion

Unable to scroll expanded fragment

I've implemented a viewpager + tabs as the expanded fragment. Each viewpager has a recyclerview. I'm able to swipe left and right with no problems, however, swipping up/down is not possible!

Hint

Is there a way to set a hint?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.