Android: Expand/collapse animation

后端 未结 30 2515
说谎
说谎 2020-11-22 05:01

Let\'s say I have a vertical linearLayout with :

[v1]
[v2]

By default v1 has visibily = GONE. I would like to show v1 with an expand animat

30条回答
  •  无人共我
    2020-11-22 05:47

    I would like to add something to the very helpful answer above. If you don't know the height you'll end up with since your views .getHeight() returns 0 you can do the following to get the height:

    contentView.measure(DUMMY_HIGH_DIMENSION, DUMMY_HIGH_DIMENSION);
    int finalHeight = view.getMeasuredHeight();
    

    Where DUMMY_HIGH_DIMENSIONS is the width/height (in pixels) your view is constrained to ... having this a huge number is reasonable when the view is encapsulated with a ScrollView.

提交回复
热议问题