A horizontal view scroller library for Android

Overview

View Flow for Android

ViewFlow is an Android UI widget providing a horizontally scrollable ViewGroup with items populated from an Adapter. Scroll down to the bottom of the page for a screen shot.

The component is a Library Project. This means that there's no need to copy-paste resources into your own project, simply add the viewflow component as a reference to any project.

When to use

This library might be suitable if you have an indeterminate number of views in your viewflow, if instead you have a static numbers of views you ought to look at Fragments and the ViewPager in the Compatibility Library instead.

Usage

In your layout

<org.taptwo.android.widget.ViewFlow
    android:id="@+id/viewflow"
    app:sidebuffer="5"
    />

The use of app:sidebuffer is optional. It defines the number of Views to buffer on each side of the currently shown View. The default sidebuffer is 3, making up a grand total of 7 (3 * 2 + 1) Views loaded at a time (at max). To be able to use the more convenient app:sidebuffer attribute, the application namespace must be included in the same manner as the android namespace is. Please refer to the layout main.xml in the example project for a full example. Again, note that it's the application namespace and not the viewflow namespace that must be referred like xmlns:app="http://schemas.android.com/apk/res/your.application.package.here".

In your activity

ViewFlow viewFlow = (ViewFlow) findViewById(R.id.viewflow);
viewFlow.setAdapter(myAdapter);

Setting a different initial position (0 being default) is as easy as:

viewFlow.setAdapter(myAdapter, 8);

Although possible, you should not call setSelection(...) immediately after calling setAdapter(myAdapter) as that might load unnecessary views giving you a decrease in performance.

Listen on screen change events

If you need to listen to screen change events you would want to implement your own ViewFlow.ViewSwitchListener and pass it to the setOnViewSwitchListener() method.

viewFlow.setOnViewSwitchListener(new ViewSwitchListener() {
    public void onSwitched(View v, int position) {
        // Your code here
    }
});

Listen on initialize view events

If you need a lazy View initialization you would want to implement your own ViewFlow.ViewLazyInitializeListener and pass it to the setOnViewLazyInitializeListener() method.

viewFlow.setOnViewLazyInitializeListener(new ViewLazyInitializeListener() {
    public void onViewLazyInitialize(View view, int position) {
        // Your code here e.g.
        ((MyAdapter)((AbsListView)view).getAdapter()).initializeData();
    }
});

Flow Indicator

It is also possible to add a flow view indicator to your layout. The purpose of a FlowIndicator is to present a visual representation of where in the item list focus is at. You may either implement a FlowIndicator yourself or use an implementation provided by the View Flow library. The View Flow library currently supports the following indicators:

Circle Flow Indicator

This indicator shows a circle for each View in the adapter with a special circle representing the currently selected view (see screenshot below).

<org.taptwo.android.widget.CircleFlowIndicator
	android:padding="10dip" android:layout_height="wrap_content"
	android:layout_width="wrap_content" android:id="@+id/viewflowindic"
	android:background="#00000000"/>

And then you'll need to connect your ViewFlow with the FlowIndicator:

CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
viewFlow.setFlowIndicator(indic);

By default, the 'active' indicator moves smoothly from one 'inactive' indicator to the next, as the user scrolls. If you set the snap attribute to true, it will instead jump to the next position when the flow settles at the next page.

The following attributes are supported: activeColor, inactiveColor, activeType (either fill or stroke), inactiveType (either fill or stroke), fadeOut (time in ms until indicator fades out, 0 = never), radius, sync (see above).

Title Flow Indicator

This indicator presents the title of the previous, current and next View in the adapter (see screenshot below).

	<org.taptwo.android.widget.TitleFlowIndicator
		android:id="@+id/viewflowindic" android:layout_height="wrap_content"
		android:layout_width="fill_parent"
		app:footerLineHeight="2dp"
		app:footerTriangleHeight="10dp" app:textColor="#FFFFFFFF" app:selectedColor="#FFFFC445"
		app:footerColor="#FFFFC445" app:titlePadding="10dp" app:textSize="11dp" app:selectedSize="12dp"
		android:layout_marginTop="10dip"
		app:clipPadding="5dp" />

And then you'll need to connect your ViewFlow with the FlowIndicator:

	TitleFlowIndicator indicator = (TitleFlowIndicator) findViewById(R.id.viewflowindic);
	indicator.setTitleProvider(myTitleProvider);
	viewFlow.setFlowIndicator(indicator);

Building a jar file

If you rather want a jar file instead of a including the project as an android library, run ant jar in the android-viewflow/viewflow folder, to build a jar file.

Caveats

The manifest states a min sdk version of 4, which is true. But in any case you want to support an api level < 8 you will have to forward an onConfigurationChanged event to the ViewFlow from your Activity. I know this isn't a very nice solution, feel free to propose better ones!

	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		viewFlow.onConfigurationChanged(newConfig);
	}

Contributions

The following persons deserves a mention for their contributions:

Want to contribute?

GitHub has some great articles on how to get started with Git and GitHub and how to fork a project.

Contributers are recommended to fork the app on GitHub (but don't have too). Create a feature branch, push the branch to git hub, press Pull Request and write a simple explanation.

One fix per commit. If let's say a commit closes the open issue 12. Just add closes #12 in your commit message to close that issue automagically.

If you still feel uncomfortable contributing the project github-wise, don't hesistate to send a regular patch.

All code that is contributed must be compliant with Apache License 2.0.

License

Copyright (c) 2011 Patrik Åkerfeldt

Licensed under the Apache License, Version 2.0

ViewFlow for Android    ViewFlow for Android

Comments
  • Fragments support?

    Fragments support?

    Hi!

    Do you have a sample of using viewflow with fragments support?

    Sorry for using the issue system for that question, but I couldn't find a better place to ask.

    opened by franciscojunior 16
  • page frozen after setSelection() is called

    page frozen after setSelection() is called

    Hi

    I'm using the Viewflow app for one of our customers. It all seems to work fine until I set the selected page with the setSelection() method in the ViewFlow class. The pages (child views of the ViewFlow view) seem to be frozen, Android stops drawing layout updates for them.

    In my case, the pages contain list views. I can still scroll them but the layout updates are not drawn anymore. If you then switch to the next page and then go back, the page is redrawn (but is still frozen).

    It sometimes also appears on first startup, any idea what could go wrong?

    Thanks in advance! Cliff

    opened by Cliffus 10
  • How to invalidate loaded view ?

    How to invalidate loaded view ?

    In my Adapter in getView() method I call the AsyncTask for load data for current view it takes time so on view shows the progress bar

    Could you bring any suggestions how invalidate the already stored data in mLoadedViews and redraw the current selected view after execute my async task ?

    opened by Voldemar123 6
  • setSelection causing force closed

    setSelection causing force closed

    I have more than 10 views.. but if i were in the 1st view and do a set selection to the 10th view, it will cause a force closed.

    Putting an AppBuffer > 10 will help but i can't predict how many i might have since the view is loaded dynamically.

    opened by elnoxvie 5
  • MinSDK version is not correct

    MinSDK version is not correct

    Hi!

    I tried to get it work with android 1.6(API4) but there are 2 issues with that.

    • ViewFlow.java:626 View.Group.LayoutParams.MATCH_PARENT In API4 there is no MATCH_PARENT, it should be named FILL_PARENT
    • ViewFlow.java:131 protected void onConfigurationChanged(Configuration newConfig) { API4 doesn't have an onConfigurationChanged() method in AdapterView class.

    I got it working by commenting out the onConfigurationChanged method, but I don't know what this will cause.

    Would be cool if this library could maintain API4 compatibility for a little longer.

    opened by rp- 5
  • namespace complexity

    namespace complexity

    The namespace used for the widget's XML attribute seems a bit overly complex and doesn't easily allow for an example of layout code to Just Work. What's the benefit of having it be application-specific instead of something tied to the widget?

    opened by xxv 5
  • viewflow-example: not all buttons seen

    viewflow-example: not all buttons seen

    Hi! I was curious about your library, so I tried it on my device (HTC Desire, Froyo OS) by running the viewflow-example: on your screenshot all buttons from 0 to 9 are shown, whereas on mine only 0 to 6. I am going to make a screenshot for you.

    tilusnet

    opened by tilusnet 5
  • Building a jar won't include res/values/attrs.xml

    Building a jar won't include res/values/attrs.xml

    The attributes in attrs.xml is not included in the jar built with ant. Referencing the jar file will then miss the attributes when declaring the viewflow in layout xml:s. I don't know if this is possible at all. Wrote a question related to it some time ago http://stackoverflow.com/questions/6428700/android-library-project-as-compiled-jar-library

    Maybe the only way is to move the Android resource files to the referencing project and let it refernence the java code in the jar?

    From: http://developer.android.com/guide/developing/projects/index.html#considerations

    "You cannot export a library project to a JAR file A library cannot be distributed as a binary file (such as a jar file). This is because the library project is compiled by the main project to use the correct resource IDs."

    opened by likebobby 4
  • setSelection slow on certain device

    setSelection slow on certain device

    This happened when i did setSelection to switch to the desired list. It has a delay for about 4 - 7 seconds. On faster device like samsung galaxy s2 it seems to be all right but not on older or less powerful device.

    opened by elnoxvie 4
  • Compatibility with gallery

    Compatibility with gallery

    Hi I have a gallery in the views for which I would like to use ViewFlow. Unfortunately the fling event over the gallery are intercepted by the ViewFlow. is there any way to avoid that? Thierry

    opened by tlegras 4
  • 'clipPadding' property for TitleFlowIndicator is introduced.

    'clipPadding' property for TitleFlowIndicator is introduced.

    Integer value that is defined by the property is used on the left side of the left view title and on the right side of the right view title so the views can have padding to the border to the parent view. Default value is 0.

    'clipPadding' can be defined as attribute in xml layout see title_with_padding_layout.xml in viewflow_example project.

    opened by iboyko 4
  • native typeface cannot be made

    native typeface cannot be made

    i am trying to use TitleIndicator exemple. after copiying the code and adding the assert folder under app/ this error is generated:

    04-28 23:49:21.232 8098-8098/tabview.fakher.com.tabconfig E/myTAG﹕ application created !! 04-28 23:49:21.332 8098-8098/tabview.fakher.com.tabconfig E/AndroidRuntime﹕ FATAL EXCEPTION: main java.lang.RuntimeException: Unable to start activity ComponentInfo{tabview.fakher.com.tabconfig/tabview.fakher.com.tabconfig.MainActivity}: android.view.InflateException: Binary XML file line #11: Error inflating class tabview.fakher.com.tabconfig.TitleFlowIndicator at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2338) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388) at android.app.ActivityThread.access$900(ActivityThread.java:148) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5473) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670) at dalvik.system.NativeStart.main(Native Method) Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class tabview.fakher.com.tabconfig.TitleFlowIndicator at android.view.LayoutInflater.createView(LayoutInflater.java:620) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696) at android.view.LayoutInflater.rInflate(LayoutInflater.java:755) at android.view.LayoutInflater.rInflate(LayoutInflater.java:758) at android.view.LayoutInflater.inflate(LayoutInflater.java:492) at android.view.LayoutInflater.inflate(LayoutInflater.java:397) at android.view.LayoutInflater.inflate(LayoutInflater.java:353) at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:240) at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102) at tabview.fakher.com.tabconfig.MainActivity.onCreate(MainActivity.java:19) at android.app.Activity.performCreate(Activity.java:5234) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$900(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5473)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:525)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.constructNative(Native Method) at java.lang.reflect.Constructor.newInstance(Constructor.java:417) at android.view.LayoutInflater.createView(LayoutInflater.java:594)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)             at android.view.LayoutInflater.inflate(LayoutInflater.java:492)             at android.view.LayoutInflater.inflate(LayoutInflater.java:397)             at android.view.LayoutInflater.inflate(LayoutInflater.java:353)             at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:240)             at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)             at tabview.fakher.com.tabconfig.MainActivity.onCreate(MainActivity.java:19)             at android.app.Activity.performCreate(Activity.java:5234)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$900(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5473)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:525)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)             at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: native typeface cannot be made at android.graphics.Typeface.(Typeface.java:190) at android.graphics.Typeface.createFromAsset(Typeface.java:164) at tabview.fakher.com.tabconfig.TitleFlowIndicator.(TitleFlowIndicator.java:110)             at java.lang.reflect.Constructor.constructNative(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:417)             at android.view.LayoutInflater.createView(LayoutInflater.java:594)             at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)             at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)             at android.view.LayoutInflater.inflate(LayoutInflater.java:492)             at android.view.LayoutInflater.inflate(LayoutInflater.java:397)             at android.view.LayoutInflater.inflate(LayoutInflater.java:353)             at android.support.v7.app.ActionBarActivityDelegateBase.setContentView(ActionBarActivityDelegateBase.java:240)             at android.support.v7.app.ActionBarActivity.setContentView(ActionBarActivity.java:102)             at tabview.fakher.com.tabconfig.MainActivity.onCreate(MainActivity.java:19)             at android.app.Activity.performCreate(Activity.java:5234)             at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)             at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2302)             at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)             at android.app.ActivityThread.access$900(ActivityThread.java:148)             at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1319)             at android.os.Handler.dispatchMessage(Handler.java:99)             at android.os.Looper.loop(Looper.java:137)             at android.app.ActivityThread.main(ActivityThread.java:5473)             at java.lang.reflect.Method.invokeNative(Native Method)             at java.lang.reflect.Method.invoke(Method.java:525)             at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:854)             at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:670)             at dalvik.system.NativeStart.main(Native Method)

    opened by Fakher-Hakim 0
  • how to adjust the sensitivity of the switching bewteen views?

    how to adjust the sensitivity of the switching bewteen views?

    now, one of the views in my project is used to show a scrollable textview. while I scroll the textview, it is easy to active the switch view event. as the consequence, the scroll process stoped.

    so here is my question: how to adjust the trigger conditon of the switching between views?

    opened by tlemar 0
  • "ant jar" build failure

    I got following "ant jar" build failure: BUILD FAILED /Users/bournewang/Downloads/android-viewflow-master 3/viewflow/build.xml:10: /Users/bournewang/Downloads/android-viewflow-master 3/viewflow/bin does not exist.

    Total time: 0 seconds BournetekiMacBook-Pro-2:viewflow bournewang$ ant jar Buildfile: /Users/bournewang/Downloads/android-viewflow-master 3/viewflow/build.xml

    Then i add a directory with name of bin, and build again:

    jar: [jar] Building MANIFEST-only jar: /Users/bournewang/Downloads/android-viewflow-master 3/viewflow/android-viewflow.jar

    BUILD SUCCESSFUL Total time: 0 seconds

    However, the size of generated android-viewflow.jar is only 350bytes and obviously, it's not correct.

    opened by skywalkerlw 0
  • How to make the margin between images become zero?

    How to make the margin between images become zero?

    I have added the library and its working great but I need to connect all of my images horizontally. I can not find where this margin comes from but there is about 10 px margin between each pair of images.

    Can some one help me please?

    opened by kayvannj 1
Owner
Patrik Åkerfeldt
Patrik Åkerfeldt
FloatingView can make the target view floating above the anchor view with cool animation

FloatingView FloatingView can make the target view floating above the anchor view with cool animation Links 中文版 README Blog about FloatingView demo.ap

UFreedom 1.8k Dec 27, 2022
用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View.

PathAnimView 用于做Path动画的自定义View。 I have a path.I have a view. (Oh~),Path(Anim)View. 现已经找到图片->SVG->PATH的正确姿势, Now i have a pic.I have a view. Oh~,Path(A

张旭童 1.1k Oct 28, 2022
TourGuide is an Android library that aims to provide an easy way to add pointers with animations over a desired Android View

TourGuide TourGuide is an Android library. It lets you add pointer, overlay and tooltip easily, guiding users on how to use your app. Refer to the exa

Tan Jun Rong 2.6k Jan 5, 2023
Android Quilt View Library

QuiltViewLibrary QuiltView displays views of different sizes in a scrollable grid. Dependencies This library depends on gridlayout_v7 ([email protected]:

Jacob Moncur 561 Nov 20, 2022
Android library to create chat message view easily

ChatMessageView ChatMessageView helps you to create chat message view quickly like a typical chatting application. Its a container view, so you can ad

Himanshu Soni 641 Dec 24, 2022
Android library implementing a poppy view on scroll, similar to the one found in the Google Plus app

PoppyView PoppyView is a library which implements view on the bottom which come and go relative to the user scroll. It can be seen in the Google plus

Flavien Laurent 409 Nov 23, 2022
Android library for creating an expandable to full screen view inside a viewgroup composition.

Expandable Panel Android Library Check ExpandablePanel Demo application on GooglePlay: Details This Android library implements the expand by sliding l

Jorge Castillo 422 Nov 10, 2022
A simple library to let you sign (or draw lines) smoothly with your finger into a view and save it.

FingerSignView Introduction FingerSignView is a simple library that lets you finger, or draw lines, smoothly with your finger into a View and save it

Agnaldo Pereira 25 Nov 20, 2022
:star2:A cool dynamic view library

ENViews ENViews, A cool dynamic view library.All designed by Nick Buturishvili ENViews, 一个华丽丽的动效控件库,所有控件原型取自Nick Buturishvili的设计作品 Preview Original de

Est 1.8k Jan 3, 2023
View that imitates Ripple Effect on click which was introduced in Android L (for Android 2.3+)

RippleView View that imitates Ripple Effect on click which was introduced in Android L. Usage For a working implementation, Have a look at the Sample

Muthuramakrishnan Viswanathan 1.2k Dec 30, 2022
Snake View is a simple and animated linear chart for Android.

Snake View Snake library is a simple and animation line chart for Android. Latest Version How to use Configuring your project dependencies Add the lib

Txus Ballesteros 339 Dec 14, 2022
[] A simple way to "badge" any given Android view at runtime without having to cater for it in layout

Android ViewBadger A simple way to "badge" any given Android view at runtime without having to cater for it in layout. Note: If your aim is to replica

Jeff Gilfelt 3k Nov 28, 2022
Android view with both path from constructed path or from svg.

android-pathview You want to animate svg or normal Paths?<br> Change the color, pathWidth or add svg.<br> Animate the "procentage" property to make th

Georgi Eftimov 2.9k Dec 27, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Dec 29, 2022
A cool Open Source CoverFlow view for Android with several fancy effects.

FancyCoverFlow THIS PROJECT IS NO LONGER MAINTAINED! What is FancyCoverFlow? FancyCoverFlow is a flexible Android widget providing out of the box view

David Schreiber-Ranner 1.1k Nov 10, 2022
A simple, customizable and easy to use swipeable view stack for Android.

SwipeStack A simple, customizable and easy to use swipeable view stack for Android. QuickStart Include the Gradle dependency dependencies { compil

Frederik Schweiger 1.5k Dec 30, 2022
Custom android music player view.

InteractivePlayerView Custom android music player view. Screen Check it on youtube Usage(XML) Define it in your xml file. <co.mobiwise.library.Intera

Mert Şimşek 744 Dec 25, 2022
Shadow layout, shadow view for android.

ShadowViewHelper Shadow layout, shadow view for android. How to use: It's very simple to use. Gradle(Check newest version): compile 'com.github.wangji

WangJie 777 Dec 30, 2022
A velocimeter View for Android

Velocimeter A velocimeter View for Android Sample video: Youtube Velocimeter video Sample app: How to use Default colors <com.github.glomadrian.veloci

Adrián Lomas 614 Dec 4, 2022