Skip to content

Instantly share code, notes, and snippets.

@nickbutcher
nickbutcher / 1 search_bar.xml
Last active March 26, 2022 10:03
Demonstrating morphing a search icon into a search field. To do this we use an AnimatedVectorDrawable (https://developer.android.com/reference/android/graphics/drawable/AnimatedVectorDrawable.html) made up of two paths. The first is the search icon (as a single line) the second is the horizontal bar. We then animate the 'trimPathStart' property …
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
@ikew0ng
ikew0ng / ListViewUtils.java
Created June 6, 2014 08:04
Smoothly scroll listView to specified position.
public class ListViewUtils {
public static final int SCROLL_DURATION = 150;
private ListViewUtils() {}
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void scrollListView(final ListView listView, final int position) {
if (CommonUtils.hasHoneycomb()) {
listView.smoothScrollToPositionFromTop(position, 0);
listView.postDelayed(new Runnable() {