StickyScrollViewItems


Source link: https://github.com/emilsjolander/StickyScrollViewItems

StickyScrollViewItems

StickyScrollViewItems is a ScrollView subclass that allowed you to mark items inside the ScrollView as sticky. The items marked as sticky will stick to the top of the ScrollView until another sticky items comes by and pushes it out of the way.

Installing

Add the following gradle dependency exchanging x.x.x for the latest release.

dependencies {

  compile 'se.emilsjolander:StickyScrollViewItems:x.x.x' 
}

Usage

First of all replace any instance of ScrollView with StickyScrollView. So you go from this:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_height="match_parent" android:layout_width="match_parent">  <!-- scroll view child goes here --> </ScrollView>

to this:

<StickyScrollView xmlns:android="http://schemas.android.com/apk/res/android"  android:layout_height="match_parent" android:layout_width="match_parent"  android:id="@+id/sticky_scroll">  <!-- scroll view child goes here --> </StickyScrollView>

As with a regular ScrollView you are only allowed one child. But that child can contain any number of children. It is these children or any of their children that can be tagged as a sticky view. If you want t view to stick to the top when you scroll passed it add a sticky tag with the android:tag attribute to it like this:

<StickyScrollView xmlns:android="http://schemas.android.com/apk/res/android"  android:id="@+id/sticky_scroll"  android:layout_height="match_parent" android:layout_width="match_parent">
<LinearLayout
 android:layout_height="match_parent" android:layout_width="match_parent"
 android:orientation="horizontal">
 <!-- other children -->
 <View
  android:layout_height="300dp"
  android:layout_width="match_parent"
 android:tag="sticky"/>
 <!-- other children -->
</LinearLayout>  </StickyScrollView>

There are also two additional flags that can be set on views that were added to optimize performance for the most usual cases. If the view you want to stick either has transparency or does not have a constant representation than you must supply one or both of the following flags. -hastransparancy for views that have transparancy and -nonconstant for views that will change appearance during there sticky time (examples are buttons with pressed states as well as progress spinners).

So this ends up with 4 different ways to tag a view as sticky resulting is slightly different behaviour android:tag="sticky" android:tag="sticky-hastransparancy" android:tag="sticky-nonconstant" and android:tag="sticky-hastransparancy-nonconstant".

If you want to add a shadow drawable below the stuck items, you must declare a namespace to find the shadow attributes xmlns:whatever="http://schemas.android.com/apk/res-auto". Usually you do this in the root layout element in you layout.xml file. You can then specify the shadow drawable with whatever:stuckShadowDrawable="" and the shadow height with whatever:stuckShadowHeight="" in xml. Note that when left unspecified, the default shadow height is 10dip.

<StickyScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:whatever="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent" android:layout_width="match_parent"
android:id="@+id/sticky_scroll"
whatever:stuckShadowDrawable="@drawable/sticky_shadow_default"
whatever:stuckShadowHeight="50dip" >
<!-- scroll view child goes here --> </StickyScrollView>

These shadow height and drawable can also be set programatically. Note that, unlike the xml attribute, setShadowHeight(pixels) only takes the values in pixels.

StickyScrollView stickyScroll = (StickyScrollView) findViewById(R.id.sticky_scroll);
 stickyScroll.setShadowDrawable(getResources().getDrawable(

R.drawable.shadow_drawable));
 stickyScroll.setShadowHeight(50);
 // in pixels

Resources

This library allows to hide keyboard automatically.

Jockey is a music player for Android based on Google's Material Design standards. The point of Jockey is to be a simple, lightweight media player with features designed for music enthusiasts and casual listeners alike. Currently Jockey is notably lacking a few enthusiast features like gapless playback, crossfade and replay gain which may be added in the future.

Detect janky frames with Android Nougat FrameMetrics.

Long press is a View to show a popup and handle drag-release events on it, just like the new feature in Instagram for Android.

Before-After-Effect is an android library to create your amazing before after effects.Just swiping you can switch between images and create a transition that create a before after visual effect.

Java8 Optional back-port for Kotlin and Android

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