Expand ListView item with animation

后端 未结 5 1423
孤街浪徒
孤街浪徒 2020-12-04 09:35

I have a ListView. Initially, the ListView contains some data. When the user clicks on an item, another layout will be dynamically added to that it

5条回答
  •  我在风中等你
    2020-12-04 09:49

    My use case is just to have more or less text displayed. So to toggle state of a listview item from 2-6 max lines for instance one can do this. And its also animated. Animation dont look exactly smooth but...

                                if(!textDescriptionLenghtToggle) { // simple boolean toggle
                                    ObjectAnimator animation = ObjectAnimator.ofInt(
                                            textViewContainingDescription,
                                            "maxLines",
                                            6);
                                    animation.setDuration(300);
                                    animation.start();
                                } else {
                                    ObjectAnimator animation = ObjectAnimator.ofInt(
                                            textViewContainingDescription,
                                            "maxLines",
                                            2);
                                    animation.setDuration(300);
                                    animation.start();
                                }
    

提交回复
热议问题