i am implementing a listview in android which will look exactly like this and scroll
I have been doing this by setting the layout params of inflated rows in getView of my adapter but the issue which arrises due to this is that the list-view becomes jerky. i.e. it only updates the rows when one row has completely passed from screen and getView has been called giving new params to all visible rows resulting in jerks can animation be applied and can listview scroll position be preciesly taken. what i want is a smooth transition between views i.e. as the listview moves up even a little bit the inner views should scale precisely with that movement.
This was my first level implementation to solve this problem hope it helps anyone interested, The arrHeight and arrWidth are created dynamically on activity start using Bezier Path Algorithm
public class TimelinePinsAdapter extends ParentLazyAdapter {
LinearLayout ll_PinsContainer;
LinearLayout.LayoutParams llParams_PinParameters;
public TimelinePinsAdapter(Activity a, ArrayList<HashMap<String, String>> d) {
super(a, d);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
vi = convertView;
if (convertView == null)
vi = inflater.inflate(R.layout.rowsinflate, null, false);
ll_PinsContainer = (LinearLayout) vi.findViewById(R.id.item);
llParams_PinParameters =
new LinearLayout.LayoutParams(0,
(int) TimeLineActivity.arrHeight[position % 7]);
ll_PinsContainer.setLayoutParams(llParams_PinParameters);
return vi;
}
}
While trying to achieve a "curved" listview, I came across a solution by stealing from the v2 beta Android Wear support library.
The key is the new WearableRecyclerView - see all the info you need at this link. Details of how to add the support library to your project: https://developer.android.com/wear/preview/start.html
This recycler view allows you to supply a custom OffsettingHelper to achieve special transformations based on the current position of each list item.
Incidentally, you should be using a RecyclerView anyway, as this recycles your views and improves performance; this'll all but eliminate the jerky animation you mentioned as new views don't have to be created every time they appear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With