Skip to content
This repository has been archived by the owner on May 25, 2020. It is now read-only.
/ vista Public archive

Backport material design edge effects and fix arc cutoff issue

License

Notifications You must be signed in to change notification settings

kaneoriley/vista

Repository files navigation

Release License Build Status Dependency Status

Vista

Logo

Vista is a simple library that allows using Material design style edge effects on all Android devices running 4.0+. It is ported from the Android Launcher source code, which means you also have the added benefit of the edges not appearing to be cut off, which is much nicer in my honest opinion.

Usage

Vista supports 6 view types. You need to replace the view in your layout XML with the corresponding Vista version in order to see the new edge effects. The following are the names of the supported types, and their corresponding Vista counterparts:

android.widget.HorizontalScrollView: Replace with me.oriley.vista.VistaHorizontalScrollView
android.widget.ScrollView: Replace with me.oriley.vista.VistaScrollView
android.support.v4.view.ViewPager: Replace with me.oriley.vista.VistaViewPager
android.support.v4.widget.NestedScrollView: Replace with me.oriley.vista.VistaNestedScrollView
android.support.v7.widget.RecyclerView: Replace with me.oriley.vista.VistaRecyclerView

So, your XML will look something like this:

    ...

    <me.oriley.vista.VistaViewPager
        android:id="@+id/vista_view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

    ...

There are currently four custom attributes which are supported for all Vista views:

vistaColor: Sets the color of the edge glow

vistaThicknessScale: A float scale factor to determine how 'thick' the edge glow effect should be. Stock Android uses 0.75, but Vista defaults to 0.5 to suit the default arc size.

vistaEdgeScale: A float scale factor to determine how much of the view edge the glow effect should fill. Stock Android uses 0.75, which results in the ends of the glow arc being clipped. Vista defaults to 0.5 so that the arc begins and ends at the corner of the encompassing view.

vistaDisableHotspot: On versions of Android prior to Lollipop, the edge effect will always be centered along the edge of the view, rather than tracking finger movement. Set this attribute to true if you would like this behaviour to be used on Lollipop and newer devices as well.

An example of these values in use is:

    ...

    <me.oriley.vista.VistaViewPager
        android:id="@+id/vista_view_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:vistaColor="#FFFF7E00"
        app:vistaThicknessScale="4.0"
        app:vistaEdgeScale="0.33"
        app:vistaDisableHotspot="true"/>

    ...

And that's it! You now have Material Design edge effect glows available to many more users, and don't have to have the ugly cut-off arc when your views aren't filling the available space.

Gradle Dependency

  • Add JitPack.io repo to your buildscript:
repositories {
    maven { url "https://jitpack.io" }
}
  • Add the library to your module dependencies:
dependencies {
    compile 'com.github.oriley-me:vista:0.4.2'
}

If you would like to check out the latest development version, please substitute all versions for develop-SNAPSHOT. Keep in mind that it is very likely things could break or be unfinished, so stick the official releases if you want things to be more predictable.

Please checkout the sample application to familiarise yourself with the implementation details. Don't be afraid to make an issue or contact me if you have any problems or feature suggestions.

About

Backport material design edge effects and fix arc cutoff issue

Resources

License

Stars

Watchers

Forks

Packages

No packages published