=============================================================
-
1.初始化参数 设置方向等
-
2.根据动画执行进度计算高度
初始化
class ExpandLinearLayout : LinearLayout {
//是否展开,默认展开
private var isOpen = true
//第一个子view的高度,即收起保留高度
private var firstChildHeight = 0
//所有子view高度,即总高度
private var allChildHeight = 0
/**
- 动画值改变的时候 请求重新布局
*/
private var animPercent: Float = 0f
constructor(context: Context) : super(context) {
initView()
}
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet) {
initView()
}
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(
context,
attributeSet,
defStyleAttr
) {
initView()
}
private fun initView() {
//横向的话 稍加修改计算宽度即可
orientation = VERTICAL
animPercent = 1f
isOpen = true
}
}
定义一个类Exp