Create a full screen dialog with CropImageView

To create a fullscreen dialog with CropImageView in Sketchware, follow the steps given below.

1. Add an ImageView imageview1 for displaying image.

2. Add a FilePicker component fp: image/* for picking images.

3. In imageview1 onClick event use block FilePicker fp pick files.

4. Download from this url:

5. Extract at .sketchware/mysc/(Project number)/app/src/main/java/(package name)/

6. Open and change package name (package;) to your project's package name.

7. Create a more block extra. Here declare a CropImageView crp, a Bitmap image and define rotateBitmap(Bitmap).


CropUtils.CropImageView crp;

Bitmap image;

public Bitmap rotateBitmap(Bitmap bitmap){ matrix = new;

matrix.postScale((float)1, (float)1);


Bitmap bitmap2 = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);

return bitmap2;



8. Create a Custom View crop_dialog.xml, with an ImageView close, a LinearLayout crop_linear, a TextView rotate, and a TextView crop.

9.  In FilePicker onFilesPicked event put following codes:

Uri uri = null;

if (_data.getClipData() != null){

uri = _data.getClipData().getItemAt(0).getUri();

} else {

uri = _data.getData();


crp = new CropUtils.CropImageView(ProfileActivity.this);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);

lp.setMargins(0, 0, 0, 0);





crp.setAspectRatio(1, 1);

try {

ParcelFileDescriptor parcelFD = getContentResolver().openFileDescriptor(uri, "r"); fileDescriptor = parcelFD.getFileDescriptor();

image = BitmapFactory.decodeFileDescriptor(fileDescriptor);



} catch ( e) {



final Dialog dialog2 = new Dialog(ProfileActivity.this,;

dialog2.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);


ImageView close_dialog = dialog2.findViewById(;

LinearLayout crop_linear = dialog2.findViewById(;

TextView rotate = dialog2.findViewById(;

TextView crop = dialog2.findViewById(;


close_dialog.setOnClickListener(new View.OnClickListener(){


public void onClick(View v){




rotate.setOnClickListener(new View.OnClickListener(){


public void onClick(View v){

image = rotateBitmap(image);




crop.setOnClickListener(new View.OnClickListener(){


public void onClick(View v){

Bitmap bitmap = crp.getCroppedImage();



10. Save and run the project.

Code for uploading Bitmap image to Firebase:

Bitmap bitmap = crp.getCroppedImage(); baos = new;

bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);

byte[] data = baos.toByteArray();

String filename = FirebaseAuth.getInstance().getCurrentUser().getUid() + ".jpg";

fstore.child(filename).putBytes(data).addOnFailureListener(_fstore_failure_listener).addOnProgressListener(_fstore_upload_progress_listener).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {


public Task<Uri> then(Task<UploadTask.TaskSnapshot> task) throws Exception {

return fstore.child(filename).getDownloadUrl();


Code for retrieving profile data to a Map variable user_map (Here user_id is FirebaseAuth uid of the user, and user_map is a Map variable):


.addValueEventListener(new ValueEventListener() {


public void onDataChange(DataSnapshot _param1) {

GenericTypeIndicator < HashMap< String, Object>> _ind = new GenericTypeIndicator<HashMap< String, Object>>() {};

try {

user_map = _param1.getValue(_ind);

//Get keys of user_map and use them to display data in TextViews or ImageViews

} catch (Exception e) {





public void onCancelled(DatabaseError databaseError) {




  1. Help Plz. My phon can't run my app any more
    when i try to run app this error show to me.
    /storage/emulated/0/.sketchware/mysc/604/app/src/main/res/values/styles.xml:2: Error retriving parent for item: No resource found that matches the given name '@android:style/Theme.Material.Light.DarkActionBbar'.,,/
    and so on
    can you help me plz.

  2. I want to know how to create an appwidget with sketchware. Help me please

  3. Show de informação cara parabéns.


Post a Comment

Popular posts from this blog

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware