最近有需求,要写一个隐藏在底部,但是支持上下拉的菜单框,于是自己写了一个模型,刚好可以复习一下自定义view、事件分发及属性动画的知识。
废话不多说,先上效果图:
界面很简单,但是有几个难点(大神请略过):
触摸区域处理;
子控件手势拦截;
配合属性动画的使用;
先看一下布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:background="#ffc2c2">
<RelativeLayout
android:id="@+id/rl_topbar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#a9a4a4">
<ImageView
android:id="@+id/iv_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginLeft="15dp"
android:src="@drawable/arrow_top"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/rl_checkbox"