ExpandableLayout 源码分析

宋运锋
2023-12-01

https://github.com/AAkira/ExpandableLayout


带阻尼震动的效果,原来使用的是AnticipateInterpolator,差值器。

ExpandableLinearLayout



https://github.com/traex/ExpandableLayout

简介:ExpandableLayout代码量很少223行,思路清楚。值得推荐啊。



animation = new Animation()
{
    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t)
    { //16ms调用一次  
//interpolatedTime 为0到1之间的值
if (interpolatedTime == 1) isOpened = true; v.getLayoutParams().height = (interpolatedTime == 1) ? LayoutParams.WRAP_CONTENT : (int) (targetHeight * interpolatedTime); v.requestLayout(); } @Override public boolean willChangeBounds() { return true; }};animation.setDuration(duration);v.startAnimation(animation);

ExpandableLayout集成Relativelayout. 布局文件:

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
    <FrameLayout
        android:id="@+id/view_expandable_headerlayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

    <FrameLayout
        android:id="@+id/view_expandable_contentLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/view_expandable_headerlayout"/>

</RelativeLayout>



 类似资料: