MaterialSeachView


Source link: https://github.com/krishnakapil/MaterialSeachView

MaterialSeachView

Android Material Design Style Custom Search View

![Screenshot 1] ( https://github.com/krishnakapil/MaterialSeachView/blob/master/material-search.png) ![Screenshot 2] ( https://github.com/krishnakapil/MaterialSeachView/blob/master/material-search2.png)

#Usage Copy the material-search.aar file into your project libs folder. Add the following dependency into gradle.

repositories {

flatDir {

 dirs 'libs'

}
 
}

dependencies {

  compile fileTree(dir: 'libs', include: ['*.jar'])
  compile(name:'material-search', ext:'aar') 
}

Add MaterialSearchView to your layout file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity">

<android.support.v7.widget.Toolbar

android:id="@+id/toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="@android:color/darker_gray"

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"

app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

<com.search.material.library.MaterialSearchView

android:id="@+id/search_view"

style="@style/MaterialSearchViewStyle"

android:layout_width="match_parent"

android:layout_height="match_parent" />  </RelativeLayout>

Get reference to it in the Activity and set adapter. Adapter should implement Filterable.

(Check MaterialSeachView/app/src/main/java/com/search/material/materialsearch)

@Override
  protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

....

MaterialSearchView searchView = (MaterialSearchView) findViewById(R.id.search_view);

SearchAdapter adapter = new SearchAdapter();

searchView.setAdapter(adapter);

searchView.setOnQueryTextListener(new MaterialSearchView.OnQueryTextListener() {

 @Override

 public boolean onQueryTextSubmit(String query) {

  return false;

 
}

  @Override

 public boolean onQueryTextChange(String newText) {

  return false;

 
}

}
);

 searchView.setOnSearchViewListener(new MaterialSearchView.SearchViewListener() {

 @Override

 public void onSearchViewShown() {

  
}

  @Override

 public void onSearchViewClosed() {

  
}

}
);

 searchView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

 @Override

 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

  
}

}
);

  
}

 @Override
  public boolean onCreateOptionsMenu(Menu menu) {

// Inflate the menu; this adds items to the action bar if it is present.

getMenuInflater().inflate(R.menu.menu_main, menu);

 MenuItem item = menu.findItem(R.id.action_search);

searchView.setMenuItem(item);

 return true;
  
}

Handle Voice search

@Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {

if (requestCode == MaterialSearchView.REQUEST_VOICE && resultCode == RESULT_OK) {

 ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

 if (matches != null && matches.size() > 0) {

  String searchWrd = matches.get(0);

  if (!TextUtils.isEmpty(searchWrd)) {

searchView.setQuery(searchWrd, false);

  
}

 
}

  return;

}

super.onActivityResult(requestCode, resultCode, data);

  
}

Closing Search when back pressed

@Override
  public void onBackPressed() {

if (searchView.isSearchOpen()) {

 searchView.closeSearch();

}
 else {

 super.onBackPressed();

}

  
}

#Styling Material Search View

<style name="MaterialSearchViewStyle">

<!-- Background for the search bar-->

<item name="searchBackground">@android:color/white</item>

<!-- Change voice icon-->

<item name="searchVoiceIcon">@drawable/ic_action_voice_search</item>

<!-- Change clear text icon-->

<item name="searchCloseIcon">@drawable/ic_action_navigation_close</item>

<!-- Change up icon-->

<item name="searchBackIcon">@drawable/ic_action_navigation_arrow_back</item>

<!-- Change background for the suggestions list view-->

<item name="searchSuggestionBackground">...</item>

<!-- Change text color for edit text. This will also be the color of the cursor-->

<item name="android:textColor">@android:color/black</item>

<!-- Change hint text color for edit text-->

<item name="android:textColorHint">@android:color/black</item>

<!-- Hint for edit text-->

<item name="android:hint">@string/search_hint</item>  </style>

Resources

AKParallax-Android is a library project that provides a parallax effect to an ImageView in a ScrollView or a ListView.

This is a simple showcase to show off some cool new stuff which is (new) in Android Lollipop.

This includes features like:

  • Toolbar
  • RecyclerView
  • CardView
  • ActionBarDrawerToggle
  • Animations (Including animations for the RecyclerView)
  • Floating Action Button (FAB)
  • RippleDrawables
  • Android Compat Theme
  • DrawerLayout

Golgi's robust Mobile Cloud Service simplifies application connectivity and data transport so developers can focus on building great app experiences.​

Features:

  • Mobile Cloud Service
  • Intelligent Delivery Engine
  • Developer Defined Data Contract
  • Multi-Layered Security
  • Cross-platform (Android/iOS/J2SE/JavaScript)

Divide.io is an open source Backend-as-a-Service (BaaS). It provides tools to easily, securely, and efficiently communicate between your app and a server. It handles data storage, user registration & management, and push notifications.

Deploy anywhere. Use any database you want. Never get locked into a platform.

circled-picker is an awesome, simple circular picker for Android. It can display value in four formats: hours, seconds, percentage and numeric, and it provides a basic set of parameters to customize.

Online tool for converting SVG to Android VectorDrawable XML resource file.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes