CropViewLayout¶
Add: Version 0.5.0
Quick start¶
Add: Version 0.5.0
<com.ave.vastgui.tools.view.cropview.CropViewLayout
android:id="@+id/cropview_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Use of Cropping¶
Calling the system cropping application¶
Using CropIntent to call the system cropping application.
VastCropActivity¶
Add: Version 0.5.0
VastCropActivity is the default cropping application. You can easily use it in the following ways.
<activity
android:name="com.ave.vastgui.tools.activity.app.VastCropActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
val intent = Intent(this, VastCropActivity::class.java).apply {
data = originalImageUri
putExtra(VastCropActivity.FRAME_TYPE, VastCropActivity.FRAME_TYPE_GRID9)
putExtra(VastCropActivity.OUTPUT_X, 300f)
putExtra(VastCropActivity.OUTPUT_Y, 300f)
}
VastCropActivity
Click VastCropActivity to get more information.
Frame type¶
Add: Version 0.5.0 Update: Version 1.5.2
The frame type can be set by crop_frame_type or calling cropFrameType .
| Type | Example | Type | Example |
|---|---|---|---|
| CIRCLE | ![]() |
SQUARE | ![]() |
| GRID9 | ![]() |
RECTANGLE | ![]() |
binding.cropViewLayout.cropFrameType = CropFrameType.CIRCLE
<com.ave.vastgui.tools.view.cropview.CropViewLayout
...
app:crop_frame_type="circle" />
Frame size¶
Add: Version 0.5.0 Update: Version 1.5.2
The size of the preview frame is related to the shape of the preview frame, if the shape of the preview frame is RECTANGLE, the size of the preview frame can be set by crop_frame_width and crop_frame_height or call setCropFrameSize(Float, Float).
binding.cropViewLayout.setCropFrameSize(50f.DP, 50f.DP)
<com.ave.vastgui.tools.view.cropview.CropViewLayout
...
app:crop_frame_width="50dp"
app:crop_frame_height="50dp" />
If the shape is CIRCLE, SQUARE or GRID9, the size of the preview frame can be set by crop_frame_size or call setCropFrameSize(Float).
binding.cropViewLayout.setCropFrameSize(50f.DP)
<com.ave.vastgui.tools.view.cropview.CropViewLayout
...
app:crop_frame_size="50dp" />
Mask color¶
Add: Version 0.5.0 Update: Version 0.5.3
The mask color can be set by crop_mask_layer_color or calling setCropMaskColor .
binding.cropViewLayout.setCropMaskColor(Color.RED)
<com.ave.vastgui.tools.view.cropview.CropViewLayout
...
app:crop_mask_layer_color="@color/red" />
Alpha of mask color
It is recommended to use a color with transparency for better effect.
Stroke color¶
Add: Version 0.5.0
The stroke color of the frame can be set by crop_frame_stroke_color or calling setCropFrameStrokeColor .
binding.cropViewLayout.setCropFrameStrokeColor(Color.RED)
<com.ave.vastgui.tools.view.cropview.CropViewLayout
...
app:crop_frame_stroke_color="@color/red" />
Output image¶
Add: Version 0.5.0 Update: Version 1.5.2
Compatibility with Android 9(API 28)¶
val bitmap:Bitmap? = binding.cropViewLayout.getCroppedImageApi28(outputX,outputY)
Compatibility under Android 9¶
val bitmap:Bitmap? = binding.cropViewLayout.getCroppedImage(outputX,outputY)





