Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layout params not working properly #117

Closed
rizwan321 opened this issue Mar 26, 2018 · 10 comments
Closed

layout params not working properly #117

rizwan321 opened this issue Mar 26, 2018 · 10 comments

Comments

@rizwan321
Copy link

rizwan321 commented Mar 26, 2018

hey u did a great work looking for this implementation from many many days

I just integrated your library with source code. because i need some customization.

so my requirement is to wrap the height of the container containing boards

i just change layout params

from
LayoutParams params = new LayoutParams(mColumnWidth, LayoutParams.MATCH_PARENT);

to
LayoutParams params = new LayoutParams(mColumnWidth, LayoutParams.WRAP_CONTENT);

height is working good when i arrive to page first time.
but the problem occur when i drag and drop items from one boards to another board.

please take a look i have added a screenshot

issue i am facing

screenshot_4

screenshot_3

view without drag drop is fine

please let me know what is wrong there.

@woxblom
Copy link
Owner

woxblom commented Mar 26, 2018

Which layout did you change to wrap_content for height? What line did you change?

I changed line 747 and that seems to work for me.

@rizwan321
Copy link
Author

i forgot to told u about all changes i made.

1 set custom layout in BoardFragment.java
final ItemAdapter listAdapter = new ItemAdapter(mItemArray, R.layout.column_item, R.id.item_layout, true);

2 change line in BoardView.Java

layout.setOrientation(LinearLayout.VERTICAL);
LayoutParams params = new LayoutParams(mColumnWidth, LayoutParams.WRAP_CONTENT);

layout.setLayoutParams(params);

    if (header != null) {
        layout.addView(header);
        mHeaders.put(mLists.size(), header);
    }
    layout.addView(recyclerView);

3 change ids in BoardFragment.java for drag drop reference

CharSequence text = ((TextView) clickedView.findViewById(R.id.tv_column_name)).getText();
((TextView) dragView.findViewById(R.id.# tv_column_name)).setText(text);
CardView dragCard = ((CardView) dragView.findViewById(R.id.card));
CardView clickedCard = ((CardView) clickedView.findViewById(R.id.card));

@woxblom
Copy link
Owner

woxblom commented Mar 26, 2018

Hm cant really see the problem here. Can you please send med the app in mail, or a test app with the problem visible so I can debug it.

@rizwan321
Copy link
Author

i have uploaded code
https://www.dropbox.com/s/72a3p0zhwwrw8qh/DragListView.zip?dl=0
please take a look

you can reproduce the issue by dragging 3rd column 1st row into 2nd column at any row

@woxblom
Copy link
Owner

woxblom commented Mar 27, 2018

Hm, something is weird when I unpack the zip. Git thinks that all files has been changed and I can not start the app. Can't even sync gradle.

Can you please commit the changes you have made (you don't need to push to your remote) and then zip it again. Like that I can just checkout the last commit and get your changes. Now it is impossible for me to see you changes as git thinks all files has been changed for some reason.

@rizwan321
Copy link
Author

done here is the new link
after code commit
https://www.dropbox.com/s/hjpmktwh492l4jc/DragListView_new.zip?dl=0

@woxblom
Copy link
Owner

woxblom commented Mar 27, 2018

Ok found the problem.

You can not use the same Drawable for all column. Every column needs its own drawable otherwise they will share the size when it is updated somehow. So instead of setting the Drawable in setBoardDrawable() set the drawable resource id like setBoardDrawableId(int resId). Then set the drawable if the resId has been set.

if (getBoardDrawableId() != -1) {
    layout.setBackgroundResource(getBoardDrawableId());
}

@rizwan321
Copy link
Author

i did not understand where i need to change.
i need Drawable object instead of integer.

@woxblom
Copy link
Owner

woxblom commented Mar 27, 2018

  1. Change you BoardView:setBoardDrawable(Drawable drawable) to BoardView:setBoardDrawableId(int id)
  2. Save an int instead of a Drawable as a member variable in BoardView. private int mBoardDrawableId = -1;
  3. Use the resource int instead of the drawable when setting the background as shown above.
  4. From BoardFragment call mBoardView.setBoardDrawable(R.drawable.column_shape);
// In BoardFragment
mBoardView.setBoardDrawable(R.drawable.column_shape);
......

// In BoardView
private int boardDrawableId = -1;
public int getBoardDrawableId() {
    return boardDrawableId;
}

public void setBoardDrawable(int resId) {
    this.boardDrawableId = resId;
}

..........

// set background color of board items
if (getBoardDrawableId() != -1) {
    layout.setBackgroundResource(getBoardDrawableId());
}

@rizwan321
Copy link
Author

it means i just need to set backgroundresoruce instread of background.
awsome.
great work
great thanks for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants