mrKlar / PagedDragDropGrid

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

Extra pixels around each item #29

Open JAlcaraz opened 11 years ago

JAlcaraz commented 11 years ago

How can i get rid of the extra space around each item? It seems a default behaviour that i cannot override from my xml layout. In GridView I think this can be done with the property android:listSelector="@android:color/transparent".

Any ideas? Thanks in advance.

mrKlar commented 11 years ago

Do you talk about the background of each item's view or the space between the items?

JAlcaraz commented 11 years ago

I mean the space between the elements.

JAlcaraz commented 11 years ago

Although in my xml there is no padding, margin, etc.. items are always slightly apart, unless I specify a width for the entire set ...

JAlcaraz commented 11 years ago

In particular what I do is to specify values ​​for variables widthMode and heighMode. That way extra spaces go away. I don't know if this makes any sense for you...

mrKlar commented 11 years ago

Well, i have a hard time just figuring what that extra space is. Could you send a picture?

JAlcaraz commented 11 years ago

Would like to get what appears on the image on the right. Is it possible?

clearextraspace

mrKlar commented 11 years ago

In auto mode, the grid will try to fit the maximum number of item in a row. It is your item view created in your adapter that specify its size.

In the example, the padding is 15, so the extra space comes from that padding + the space needed to lay the items evenly in the row.

You can manually specify the row and column count. If you go that route, the grid will resize the items so they will fit with the specified values.

JAlcaraz commented 11 years ago

Thank you so much for the clarification. Now i'm trying to add some margin to the entire ScrollView and this is what i get:

clearextraspace_globalmargins

The code for the ScrollView is:

<ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="10dp"
    android:layout_marginRight="10dp">

    <ca.laplanete.mobile.pageddragdropgrid.PagedDragDropGrid
        android:id="@+id/gridview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
/>

</ScrollView>

The entire set moves to the left when there is space enough to fill the remaining gaps and be centered. Any clues?

mrKlar commented 11 years ago

Well, the scroll view wrapping in the example is kind of an ugly patch for the lack of vertical scrolling in the grid.
The vertical scroll for each page is in dev, but is a big rewrite so i do not have a release date.

My guess is the grid does not know about the scrollview margin so it takes the screen width to compute its page width. Try to put a margin in both to see...