mrKlar / PagedDragDropGrid

An Android ViewGroup that implements a paged grid with drag'n'drop moveable items
406 stars 184 forks source link

Various item's sizes #20

Closed iosand closed 11 years ago

iosand commented 11 years ago

Hi, I would like to populate a page with relative layouts that have various sizes (for example, to have four items/views/buttons with various sizes on one or more pages). I know that I can set layouts params in ExamplePagedDragDropGridAdapter like:

    public View view(int page, int index) {

        Item item = getItem(page, index);
        RelativeLayout layout = new RelativeLayout(context);
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(250, 250);

        if (item.getName() == "v4")
        {
             layoutParams = new RelativeLayout.LayoutParams(500, 250);
        }
        else if (item.getName() == "v2")
        {
             layoutParams = new RelativeLayout.LayoutParams(500, 500);
        }
        else
        {
             layoutParams = new RelativeLayout.LayoutParams(250, 250);
        }

        ImageView buttonOn = new ImageView(context);
        buttonOn.setImageResource(item.getDrawableButtonOn());
        buttonOn.setPadding(0, 0, 0, 0);
        buttonOn.setLayoutParams(layoutParams);
        buttonOn.setTag("buttonOn");

        .
        .
    
        .

        layout.setLayoutParams(new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
        layout.addView(buttonOn);

        return layout; 
    }

but DragDropGrid.java calculate the biggest child (item/button/view) and set columns and rows size according to child's dimensions. So the question is: how to set different row and column size for each page or just get rid of columns and rows and populate all pages with items like in one big cell, but capable of dragging items, swap them, moving to next page and any other features provided by this framework.

The result should be like: grid

Thanks in advance

mrKlar commented 11 years ago

Sounds like a new feature.

You can use

/* * The fixed row count (AUTOMATIC for automatic computing) * * @return row count or AUTOMATIC / public int rowCount();

/**
 * The fixed column count (AUTOMATIC for automatic computing)
 * 
 * @return column count or AUTOMATIC
 */
public int columnCount();

to have a fixed number of row/columns.

You can't have different sizing per page/child.