android自定义View实现裁剪图片功能,不使用系统的
闲来无事,今天写了一下怎么裁剪图片,写的很烂,放在这里以后看看自己有没有进步.............
首先给个效果图了...........
1,拖动矩形框,矩形框以为是一个半透明的罩,通过画出四个半透明的矩形,出红框以内除外ia,可以实现效果
2,拖动红框及拉伸红框获取坐标,拉的只能通过红框的上面那个红线点击向外移动放大,向左里移动缩小,哈哈,还有很多地方没有做,不想做了,懒啊,有想法的时候再做吧.......
3,点击红框以外的地方时候,会保存裁剪图片,最后点击save去掉自己顶的view,把裁剪的图片放在imageview里面。(底层有个图片是本身imageview有的哦)
代码实现:
自定义view:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" > <ImageView android:id="@+id/imageview" android:layout_width="480dip" android:layout_height="360dip" android:background="@drawable/aa" /> <Button android:id="@+id/save" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="400dip" android:text="save" /> <Button android:id="@+id/cencal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_marginTop="400dip" android:text="cencal" /> <ImageView android:id="@+id/caijian" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="400dip" android:layout_centerHorizontal="true" /></RelativeLayout>
还有很多的地方不足...............如果有哪位该人能够给个简单的方法就好啊......,代码很看,可不要喷饭哦............quot;,