This share is a very common effect, all involved in shopping apps or travel and ordering apps have seen this effect, two list view linkage display, add a shopping cart when the implementation of a parabolic animation, as well as the icon or item in the upper right corner of the digital display. Here is my free time to write a demo, the interface compared to the burrow, but the basic effect has been achieved.
Not much to say, look:
Only listen to the Add button, delete not write (no need).
Talk about some of the main code, want to download the source can go here to download (https://github.com/bobge/LinkedListView.git):
The number in the upper-right corner of the ListView item on the left is shown in XML:
Shape_data.xml
<?xml version= "1.0" encoding= "UTF-8"? ><shape xmlns:android= "http://schemas.android.com/apk/res/ Android " android:shape=" Oval " android:uselevel=" false "> <solid android:color=" #f00000 "/> <padding android:left= "2DP" android:top= "1DP" android:right= "2DP" android:bottom= "1DP "/> <solid android:color=" #f00000 "/> <size android:width=" 15DP " android:height= "15DP"/></shape>
to achieve a circular middle display number just need to set the width of TextView, and then set a property of TextView as:
Android : background= "@drawable/shape_data"
Shopping Cart The number below shows that I changed the implementation: Call Badgeview This custom class can be implemented, the usage is very simple, you can search for this class.
The linkage of the two ListView is also simple:
listView1. Setonitemclicklistener (new Adapterview.onitemclicklistener () { @Override public void Onitemclick (adapterview<?> parent, view view, int position, long ID) { list2. Clear (); list2. AddAll (list. Get (position). GetList ()); goodsadapter. notifydatasetchanged (); }});
as long as the list view on the left of the listener to the right of the list view adapter notifydatasetchanged is available. The main look at my data source format should be clear.
The implementation of the parabolic animation effect, this part of the web has a lot of demo implementation, in fact, the principle is very simple, first get the coordinates of the location of the click:
int New int [2]; An integer array that stores the button's X-and y-coordinate V.getlocationinwindow (startlocation) on the screen; //This is the x, y coordinate of the Get Purchase button on the screen (this is also the coordinate at which the animation starts)
Using the same method to calculate the end position (that is, the location coordinates of the shopping cart), and then calculate the translation distance on the x, Y axis, adding Translateanimationx and Translateanimationy with Animationset is OK, Specific can go to download the source to see.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Share a shopping Cart demo (high effect like hungry software shopping effect)