Skip to content

very poor drag, or it barely can drag the images #44

Description

@hatimmakki

Hi

Edit :

The issue is ( The DragLinearLayout doesn't work with ScrollView )

I am adding ImageViews programatically, but the images can barely drag. it require very long press, sometimes it works and sometimes doesn't.

this is the adding function

Java

private void appendImageToLinearLayout(DragLinearLayout layout,
                                       ParseFile parseFileImage,
                                       int w, int h,
                                       boolean fullWidth,
                                       boolean isPostImage,
                                       final int position)
        throws ParseException, IOException {

    ImageView imageView= new ImageView(this);
    //imageView.setBackgroundResource(R.drawable.ic_action_search);
    imageView.setImageBitmap(

            ImageTools.
                    getBitmapFromUri(Uri.fromFile(
                            parseFileImage.getFile()),
                            this, fullWidth
                    )
    );

    // params
    //DragLinearLayout.LayoutParams viewParamsCenter =
            new DragLinearLayout.LayoutParams(
                    w,
                    h);
    //viewParamsCenter.gravity = Gravity.CENTER_HORIZONTAL | Gravity.RIGHT;

    //imageView.setLayoutParams(viewParamsCenter);
    imageView.setId(position);
    imageView.setContentDescription(imageList.get(position).getObjectId());
    layout.addDragView(imageView, imageView);

    //layout.setViewDraggable(imageView, imageView);

    if(isPostImage){

        imageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //showImageFullScreen(position);
                Toast.makeText(EditPostActivity.this, "clicked " + v.getId(), Toast.LENGTH_SHORT).show();
            }
        });
    }
}

XML

<ScrollView
    android:id="@+id/llCanvusContainer"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginTop="8dp"
    android:background="@android:color/white"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/switchIsPublic">

    <com.jmedeisis.draglinearlayout.DragLinearLayout
        android:id="@+id/llCanvus"
        style="@style/Gallery19crollbarStyle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/switchIsPublic" />

</ScrollView>

The images show correctly, but the dragging doesn't work correctly.

#note:
the drag and drop works fine when I remove the ScrollView

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions