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

Doesn't render when the child is a GridView #45

Closed
xarlotie opened this issue Jul 9, 2018 · 3 comments
Closed

Doesn't render when the child is a GridView #45

xarlotie opened this issue Jul 9, 2018 · 3 comments

Comments

@xarlotie
Copy link

xarlotie commented Jul 9, 2018

    <com.otaliastudios.zoom.ZoomLayout
        android:id="@+id/zoom"
        android:layout_width="320dp"
        android:layout_height="500dp"
        android:scrollbars="vertical|horizontal"
        app:overScrollHorizontal="true"
        app:overScrollVertical="true"
        app:overPinchable="true"
        app:horizontalPanEnabled="true"
        app:verticalPanEnabled="true"
        app:zoomEnabled="true"
        app:minZoom="0.7"
        app:minZoomType="zoom"
        app:maxZoom="3.0"
        app:maxZoomType="zoom"
        app:hasClickableChildren="true">

        <GridView
            android:id="@+id/gridview"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none"
            android:numColumns="30"
            android:verticalSpacing="2dp"
            android:horizontalSpacing="2dp"
            android:stretchMode="columnWidth"
            android:gravity="center"
            android:overScrollMode="never"
            android:fadingEdge="none" />

    </com.otaliastudios.zoom.ZoomLayout>

I don't see the gridview when I try this code. Also, when the width and height of the zoomlayout are match_parent, it throws a RuntimeException saying ZoomLayout must be used with fixed dimensions. Any help?

@markusressel
Copy link
Collaborator

I think this is because you use

android:layout_width="match_parent"
android:layout_height="wrap_content"

in your GridView. Afaik GridView by default does not support wrap_content. You can try to set absolute dimensions on your GridView programmatically after the parent ZoomLayout has been layouted using something like this:

final GridView gridView = findViewById(R.id.gridview);
zoomLayout.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
    @Override
    public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
        ViewGroup.LayoutParams params = gridView.getLayoutParams();
        params.width = v.getWidth();
        params.height = v.getHeight();
        gridView.setLayoutParams(params);
    }
});
gridView.setAdapter(new GridViewAdapter());

But I haven't tested this.

The main problem here is (again) that a GridView is scrollable. This interferes with the scroll of the ZoomLayout parent. I don't know if it is possible to disable the scroll on a GridView but you would have to do this to avoid issues with that too.

@markusressel
Copy link
Collaborator

markusressel commented Feb 6, 2019

@xarlotie Take a look at the issue/gridview branch I created.
It works for me, although I would suggest using a different layout instead of GridView because of the scrolling issues. ZoomLayout should be the only view that controls scroll and zoom.

@markusressel
Copy link
Collaborator

Closing because of inactivity.

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

No branches or pull requests

2 participants