GridView and ListView control swipe animation effect
----------------------------------------------------------------------------
The learning content comes from the excellent source code of GitHub
https://github.com/twotoasters/JazzyListView
Contains two parts:
1、JazzyGridView
2、JazzyListView
GridView and ListView control swipe animation effect
Download (only include the source code src file and res/values/attrs.xml file, all source code can be downloaded from GitHub):
http://yunpan.cn/cFJxMmVWq8Bb7 (extraction code: c808)
1. Use steps:
1. Preparation:
Copy the res/values/attrs.xml file in the source code to the corresponding location of the personal project
Copy the com folder under the src folder in the source code to the src folder of the personal project
It can be seen that there are sliding animation effects in the effects folder, and there are four other java class files.
Second, the use of jazzyGridView
1. Add the jazzyGridView control to the layout file (note the label name package name + class name):
<com.twotoasters.jazzylistview.JazzyGridView android:id="@+id/gridView" android:numColumns="3" android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" ></com.twotoasters.jazzylistview.JazzyGridView>
2. Use the same as the normal use of the GridView control. Add data sources and adapters
private GridViewAdapter adapter; private List<String> list ; private JazzyGridView gridView;
list = new ArrayList<String>(); for (int i = 1; i < 60; i++) { list.add(i+""); } adapter = new GridViewAdapter(this,list); gridView = (JazzyGridView) findViewById(R.id.gridView); gridView.setAdapter(adapter);
3. Set the animation effect for the jazzyGridView control. The parameter can be any animation effect class under the effects folder in the java file. We can also modify the animation effect on the basis of the source code author for actual needs.
gridView.setTransitionEffect(new HelixEffect());
4. Effect picture:
Third, the use of jazzyListView
1. Add the jazzyListView control to the layout file (note the label name package name + class name):
<com.twotoasters.jazzylistview.JazzyListView
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
2. Use the same as the normal use of the ListView control. Add data sources and adapters
private List<String> list ;
private JazzyListView listView;
private ArrayAdapter<String> adapter;
listView = (JazzyListView) findViewById(R.id.list);
list = new ArrayList<String>();
for(int i=0;i<30;i++){
list.add("第"+i+"个列表项");
}
adapter = new ArrayAdapter<String>(this, R.layout.item,list);
listView.setAdapter(adapter);
3. Set the animation effect for the jazzyListView control, the parameter can be any animation effect class under the effects folder in the java file
listView.setTransitionEffect(new TwirlEffect());
4. Effect picture: