在不改变触发对象的情况下,增加点击区域的控件。如果不使用该控件,我们也可以在,比如按钮外面在加个布局,如RelativeLayout、LinearLayout, 但是这样必须把事件绑定到容器上,而不是按钮上。项目地址:https://github.com/lnikkila/ExtendedTouchView 效果图:如何使用使用很简单,就是把想要增加区域的view的外面加个<com.lnikkila.extendedtouchview.ExtendedTouchView>:<com.lnikkila.extendedtouchview.ExtendedTouchView
android:id="@ id/touch_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center_horizontal"
app:touchHeight="200dp">
<Button
android:id="@ id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button"/>
</com.lnikkila.extendedtouchview.ExtendedTouchView>然后通过属性touchWidth、touchHeight设置触碰区域的宽高。
评论0
最新资源