ScaleAnimation Scale Axis Definition

I have an idea that I am scaling a list that simulates scaling a list of items vertically in full screen mode.

Here's an example github project to play with animation code here

enter image description here

The code is as follows:

<FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <View android:id="@+id/growView" android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/fiftyBlack" /> </FrameLayout> 

and

 view.setOnClickListener { val listItemHeight = it.measuredHeight val toolBarHeight = (it.parent as RecyclerView).y val scalingView = it.rootView.findViewById<View>(R.id.growView) val screenHeight = (scalingView.parent as FrameLayout).measuredHeight // Position the view exactly over the list item scalingView.y = it.y + toolBarHeight scalingView.layoutParams.height = listItemHeight scalingView.layoutParams = scalingView.layoutParams /* pivots[0] scales example animation for the first item of the list for xxhdpi: 1080p device for the rest of the visible items the pivots are: 1.954f, 3.131f .... +1.177 (no scroll) */ val pivots = arrayListOf(0.777f) val itemScale = screenHeight.toFloat()/listItemHeight val scaleAnime = ScaleAnimation(1f, 1f, 1f, itemScale, Animation.RELATIVE_TO_SELF, 0f, Animation.RELATIVE_TO_SELF, pivots[0]) scaleAnime.setDuration(400); scaleAnime.setFillAfter(true); scalingView.startAnimation(scaleAnime); 

As you can see, the problem is determining the pivot point y for each element:

 val scaleAnime = ScaleAnimation( /.....* Dynamic vertical pivot */) 

I struggle for a few days to determine the fulcrum, but I can’t understand what it depends on.

Any ideas what this could be?

+5
source share

Source: https://habr.com/ru/post/1274040/


All Articles