Ramotion / garland-view-android

:octocat: ≡ GarlandView seamlessly transitions between multiple lists of content. Made by @Ramotion
https://www.ramotion.com/garland-view-android/
MIT License
1.83k stars 254 forks source link

Scrolling bugged with only few inner items? #8

Closed vb1508 closed 5 years ago

vb1508 commented 6 years ago

Hi,

I tried to use garland view in my project but I'm experiencing a pretty wierd issue. Whenever I have only one or two items in my InnerAdapter - such that they do not fill out the screen and I shouldn't be able to scroll - and when I eventually try to scroll, the InnerItems would just drop to the bottom and then disappear offscreen. I tried using the same code as from the example but had the same issue. Is it a bug or am I doing something wrong?

Thanks

EDIT: I also tried to include a SearchView widget within the OuterItem, and every time I clear the search (e.g. pressing on "x") the adapter would automatically rotate to the previous outer item. Anyway to prevent this?

dvg4000 commented 6 years ago

@vb1508 for the first issue, you'll need to wait for version update. For the second issue, you can try this workaround:

public class Transformer extends com.ramotion.garlandview.header.HeaderTransformer {

    @Override
    public void transformPage(@NonNull HeaderItem item, float scrollPosition) {
        super.transformPage(item, scrollPosition);

        if (scrollPosition == -1f || scrollPosition == 1f) {
            ((ViewGroup)item.itemView).setDescendantFocusability(ViewGroup.FOCUS_BLOCK_DESCENDANTS);
        } else if (scrollPosition == 0) {
            ((ViewGroup)item.itemView).setDescendantFocusability(ViewGroup.FOCUS_AFTER_DESCENDANTS); // or ViewGroup.FOCUS_BEFORE_DESCENDANTS
        }
    }
}

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        ...
        final TailRecyclerView rv = findViewById(R.id.recycler_view);
        final TailLayoutManager lm = (TailLayoutManager) rv.getLayoutManager();
        lm.setPageTransformer(new Transformer());
        ...
    }
    ...
}
vb1508 commented 6 years ago

Hi,

I tried out the new version and everything is working fine. Is there a way to enable nested scrolling inside the header item (e.g. a horizontal recyclerview)?

mejdi14 commented 5 years ago

Hi vb1508, can you tell how did you manage to add a filter to this list.