Skip to content
Newer
Older
100644 129 lines (83 sloc) 6.83 KB
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
1 # View Flow for Android
2
1483749 @pakerfeldt Minor readme fix
authored May 7, 2011
3 ViewFlow is an Android UI widget providing a horizontally scrollable [ViewGroup](http://developer.android.com/reference/android/view/ViewGroup.html) with items populated from an [Adapter](http://developer.android.com/reference/android/widget/Adapter.html). Scroll down to the bottom of the page for a screen shot.
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
4
a101b7b @pakerfeldt Copy/paste issue
authored May 7, 2011
5 The component is a [Library Project](http://developer.android.com/guide/developing/eclipse-adt.html#libraryProject). 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.
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
6
28e4511 @pakerfeldt Update README.md
authored Jan 5, 2012
7 ## When to use
8 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.
9
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
10 ## Usage
11
12 ### In your layout
13
3de429d @pakerfeldt Changing namespace in README
authored May 7, 2011
14 <org.taptwo.android.widget.ViewFlow
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
15 android:id="@+id/viewflow"
16 app:sidebuffer="5"
17 />
18
19 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).
7aa2f59 @pakerfeldt Edited README.md via GitHub
authored Jul 31, 2011
20 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"`.
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
21
22 ### In your activity
23
24 ViewFlow viewFlow = (ViewFlow) findViewById(R.id.viewflow);
25 viewFlow.setAdapter(myAdapter);
01e2336 @pakerfeldt Adding information about initial position.
authored Aug 5, 2011
26
27 Setting a different initial position (0 being default) is as easy as:
28
29 viewFlow.setAdapter(myAdapter, 8);
30
7dacaca @pakerfeldt Clarification in readme.
authored Aug 5, 2011
31 Although possible, you should not call `setSelection(...)` immediately after calling `setAdapter(myAdapter)` as that might load unnecessary views giving you a decrease in performance.
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
32
33 ### Listen on screen change events
34
35 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.
36
37 viewFlow.setOnViewSwitchListener(new ViewSwitchListener() {
f40a6a0 @pakerfeldt Solves #6
authored May 24, 2011
38 public void onSwitched(View v, int position) {
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
39 // Your code here
40 }
41 });
42
ffd3a14 @chripo Changed README to reflect ViewLazyInitializeListener
chripo authored Apr 14, 2012
43 ### Listen on initialize view events
44
45 If you need a lazy View initialization you would want to implement your own `ViewFlow.ViewLazyInitializeListener` and pass it to the `setOnViewLazyInitializeListener()` method.
46
47 viewFlow.setOnViewLazyInitializeListener(new ViewLazyInitializeListener() {
48 public void onViewLazyInitialize(View view, int position) {
49 // Your code here e.g.
50 ((MyAdapter)((AbsListView)view).getAdapter()).initializeData();
51 }
52 });
53
afc40c1 @pakerfeldt Updating README and screen shot
authored May 11, 2011
54 ### Flow Indicator
61d1084 @pakerfeldt Updating readme and screen dumps.
authored May 21, 2011
55 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:
56
57 #### Circle Flow Indicator ####
de79ace @pakerfeldt Changing README to reflect changes in CircleFlowIndicator.
authored Aug 30, 2011
58 This indicator shows a circle for each `View` in the adapter with a special circle representing the currently selected view (see screenshot below).
afc40c1 @pakerfeldt Updating README and screen shot
authored May 11, 2011
59
60 <org.taptwo.android.widget.CircleFlowIndicator
61 android:padding="10dip" android:layout_height="wrap_content"
62 android:layout_width="wrap_content" android:id="@+id/viewflowindic"
63 android:background="#00000000"/>
64
65 And then you'll need to connect your `ViewFlow` with the `FlowIndicator`:
e70cb64 @pakerfeldt Cosmetic fix
authored May 11, 2011
66
afc40c1 @pakerfeldt Updating README and screen shot
authored May 11, 2011
67 CircleFlowIndicator indic = (CircleFlowIndicator) findViewById(R.id.viewflowindic);
68 viewFlow.setFlowIndicator(indic);
de79ace @pakerfeldt Changing README to reflect changes in CircleFlowIndicator.
authored Aug 30, 2011
69
70 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`.
afc40c1 @pakerfeldt Updating README and screen shot
authored May 11, 2011
71
61d1084 @pakerfeldt Updating readme and screen dumps.
authored May 21, 2011
72 #### Title Flow Indicator ####
73 This indicator presents the title of the previous, current and next `View` in the adapter (see screenshot below).
74
75 <org.taptwo.android.widget.TitleFlowIndicator
76 android:id="@+id/viewflowindic" android:layout_height="wrap_content"
77 android:layout_width="fill_parent"
3044c56 @pakerfeldt Solves #25
authored Aug 2, 2011
78 app:footerLineHeight="2dp"
79 app:footerTriangleHeight="10dp" app:textColor="#FFFFFFFF" app:selectedColor="#FFFFC445"
b4063cd @pakerfeldt Size of selected title will default to size of unselected titles if n…
authored Aug 6, 2011
80 app:footerColor="#FFFFC445" app:titlePadding="10dp" app:textSize="11dp" app:selectedSize="12dp"
3c18358 @pakerfeldt Adding clipPadding attribute to example in README.
authored Jul 27, 2011
81 android:layout_marginTop="10dip"
3044c56 @pakerfeldt Solves #25
authored Aug 2, 2011
82 app:clipPadding="5dp" />
61d1084 @pakerfeldt Updating readme and screen dumps.
authored May 21, 2011
83
84 And then you'll need to connect your `ViewFlow` with the `FlowIndicator`:
85
86 TitleFlowIndicator indicator = (TitleFlowIndicator) findViewById(R.id.viewflowindic);
87 indicator.setTitleProvider(myTitleProvider);
88 viewFlow.setFlowIndicator(indicator);
89
d44a5f0 @pakerfeldt Adding build.xml to support building jar files from source. Solves #15.
authored Jul 6, 2011
90 ## Building a jar file
91 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.
92
97e577e @pakerfeldt Step min sdk to 4 (from 3) and actually support this api level. close #…
authored Jul 16, 2011
93 ## Caveats ##
02e8af7 @pakerfeldt Another cosmetic fix of README.
authored Jul 16, 2011
94 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!
cc24530 @pakerfeldt Cosmetic fix of README.
authored Jul 16, 2011
95
96 @Override
97 public void onConfigurationChanged(Configuration newConfig) {
98 super.onConfigurationChanged(newConfig);
99 viewFlow.onConfigurationChanged(newConfig);
100 }
97e577e @pakerfeldt Step min sdk to 4 (from 3) and actually support this api level. close #…
authored Jul 16, 2011
101
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
102 ## Contributions
61d1084 @pakerfeldt Updating readme and screen dumps.
authored May 21, 2011
103 The following persons deserves a mention for their contributions:
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
104
afc40c1 @pakerfeldt Updating README and screen shot
authored May 11, 2011
105 * Eric Taix
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
106 * Marc Reichelt, <http://marcreichelt.blogspot.com/>
107
a9cae0b @pakerfeldt Adding a section about contributing.
authored May 22, 2011
108 ### Want to contribute?
109
110 GitHub has some great articles on [how to get started with Git and GitHub](http://help.github.com/) and how to [fork a project](http://help.github.com/forking/).
111
112 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.
113
6539cfa @pakerfeldt Edited README.md via GitHub
authored May 26, 2011
114 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.
a9cae0b @pakerfeldt Adding a section about contributing.
authored May 22, 2011
115
116 If you still feel uncomfortable contributing the project github-wise, don't hesistate to send a regular patch.
117
118 All code that is contributed must be compliant with [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0.html).
119
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
120 ## License
121 Copyright (c) 2011 [Patrik Åkerfeldt](http://about.me/pakerfeldt)
122
123 Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)
124
8e94044 @pakerfeldt Cosmetic.
authored May 21, 2011
125 ![ViewFlow for Android](https://github.com/pakerfeldt/android-viewflow/raw/master/viewflow-example/screen.png "ViewFlow for Android") &nbsp;&nbsp; ![ViewFlow for Android](https://github.com/pakerfeldt/android-viewflow/raw/master/viewflow-example/screen2.png "ViewFlow for Android")
61d1084 @pakerfeldt Updating readme and screen dumps.
authored May 21, 2011
126
2424107 @pakerfeldt Adding screen shot to README
authored May 7, 2011
127
ea9515c @pakerfeldt Moving to public repository
authored May 7, 2011
128
Something went wrong with that request. Please try again.