A simple package of general cutting picture view.
- Support three clip modes:
- CLIPTYPE1:square
- CLIPTYPE2:fixed rectangle
- CLIPTYPE3:equal proportional rectangle
- Get the resources into your project.
- import
CustomClipView.java. - import
photoUtil.javaif you need.
- Config in Xml.
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/CustomClipView_iv"
android:scaleType="matrix" />
<hxy.ttt.com.customclipview.CustomClipView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/CustomClipView" />
</RelativeLayout>- In your Activity, your must implements
View.OnTouchListenerand realization methodonTouch.
clipview = (CustomClipView) findViewById(R.id.CustomClipView);
//clipview.setClipParams(400, 400, CustomClipView.CLIPTYPE1);
Bitmap bm = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
//String image = PhotoUtil.scale(picturePath, filepath);
//Bitmap bm = BitmapFactory.decodeFile(image);
iv = (ImageView) findViewById(R.id.CustomClipView_iv);
iv.setScaleType(ImageView.ScaleType.MATRIX);
iv.setOnTouchListener(this);
iv.setImageBitmap(bm);
@Override
public boolean onTouch(View v, MotionEvent event) {
return clipview.onTouch(v, event);
}- public methods.
clipview.getBitmap(getWindow());clipview.ActionClip(getWindow(), filepath);clipview.setClipParamsDp(clipwidth, clipheight, cliptype);clipview.setClipParamsPx(clipwidth, clipheight, cliptype);
- Finally, don't forget add
uses-permission.
More usage of the CustomClipView, Please see the Sample.
Have problem? Just tweet me or send me an email.
Copyright 2016 huangxy@GitSmark
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.



