Skip to content

vikramezhil/DroidFloatingSearchView

Repository files navigation

DroidFloatingSearchView

Yet another floating search view library for android

About

An easy to implement floating search view with customizations.

Supports from Android SDK version 19 and above.

Requires androidx.

Usage

Gradle dependency:

Add the following to your project level build.gradle:

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add this to your app build.gradle:

dependencies {
    implementation 'com.github.vikramezhil:DroidFloatingSearchView:v2.0.1'
}

Add the following to the section of your pom.xml:

<repositories>
  <repository>
      <id>jitpack.io</id>
      <url>https://jitpack.io</url>
  </repository>
</repositories>

Add the following to the section of your pom.xml:

<dependency>
    <groupId>com.github.vikramezhil</groupId>
    <artifactId>DroidFloatingSearchView</artifactId>
    <version>v2.0.1</version>
</dependency>

Documentation

For a detailed documentation 📔, please have a look at the Wiki.

In your layout file add Droid Floating Search View,

<github.com.vikramezhil.dfsv.Dfsv
    android:id="@+id/dfsView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:dfsvBgColor="@android:color/holo_purple"
    app:dfsvOverlayBgColor="@android:color/holo_purple"
    app:dfsvTextColor="@android:color/white"
    app:dfsvHintTextColor="@android:color/white"
    app:dfsvDividerColor="@android:color/white"
    app:dfsvIconsColor="@android:color/white"
    app:dfsvHintText="@string/search_hint"
    app:dfsvCornerRadius="10"
    app:dfsvElevation="5"
    app:dfsvCloseSearchOnOverlayTouch="false"
    app:dfsvContinuousSearch="false"
    app:dfsvSuggestions="@array/suggestions"/>

In your class file, initialize Droid Floating Search View using the ID specified in your layout file

DroidFSView dfsView = findViewById(R.id.dfsView);

Set and implement the Droid Floating Search View listener methods

dfsView.setOnDroidFSViewListener(new OnDroidFSViewListener() {
    @Override
    public void onHasFocus() {
        Log.i(TAG, "Has focus");
    }

    @Override
    public void onLostFocus() {
        Log.i(TAG, "Lost focus");
    }

    @Override
    public void onSearchTextChanged(String oldQuery, String newQuery) {
        Log.i(TAG, "Old query = " + oldQuery + ", New Query = " + newQuery);
    }

    @Override
    public void onSearchText(String searchQuery) {
        Log.i(TAG, "Query to search = " + searchQuery);
    }

    @Override
    public void onActionItemClicked() {
        Log.i(TAG, "Action item clicked");
    }
});