缩放系列(三):一个可以手势缩放、拖拽、旋转的layout

本文介绍了如何创建一个PowerfulLayout,该布局支持双指缩放、子视图随缩放移动以及拖拽功能。同时,保持子视图原有的交互能力,如按钮点击。此外,还提到了旋转手势的实现,并提供了运行效果的链接、布局文件和简单Java代码示例,以及一个实际应用场景:类似QQ侧滑菜单的效果。
摘要由CSDN通过智能技术生成

弄了一个下午,终于搞出来了,PowerfulLayout

下面是一个功能强大的改造的例子:

可以实现以下需求:

1.两个手指进行缩放布局

2.所有子控件也随着缩放,

3.子控件该有的功能不能丢失(像button有可被点击的功能,缩放后不能丢失该功能)

相对上个例子,多了一个功能---

4.拖拽(平移)layout

 运行效果图:http://pan.baidu.com/s/1geIoG8r

图片太大就不贴出来了。

 

布局文件test.xml、超级简单的

<?xml version="1.0" encoding="utf-8"?>
<com.example.testbitmapscale.PowerfulLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    and
DragLinearLayout一个LinearLayout, 他可是其子View在其范围内可拖动、可交换位置。默认情况下,子View是不可拖动的,你需要调用DragLinearLayout.setViewDraggable(child, child)方法让其可拖动。项目地址:https://github.com/justasm/DragLinearLayout 效果图:如何使用和使用LinearLayout一样:                        2. 让子View可拖动默认情况下子View是不可拖动的,你需要调用dragLinearLayout.setViewDraggable()让子View变为可拖动的。DragLinearLayout dragLinearLayout = (DragLinearLayout) findViewById(R.id.container); //让子view可拖动,默认是不能拖动的         for(int i = 1; i < dragLinearLayout.getChildCount(); i ){             View child = dragLinearLayout.getChildAt(i);             dragLinearLayout.setViewDraggable(child, child);          }可以动态添加可拖动子viewfinal View view = View.inflate(context, R.layout.view_layout, null); dragLinearLayout.addDragView(view, view.findViewById(R.id.view_drag_handle));   // ..   dragLinearLayout.removeDragView(view);使用OnViewSwapListener检测子view之间的排序变化事件:dragLinearLayout.setOnViewSwapListener(new DragLinearLayout.OnViewSwapListener() {     @Override     public void onSwap(View firstView, int firstPosition,             View secondView, int secondPosition) {         // update data, etc..     } });当在ScrollView中使用DragLinearLayout的时候,如果你想在拖拽的时候ScrollView也能滚动,需要调用setContainerScrollView(Scroll
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值