문제

I'm trying to use Etsy's Staggered Gridview (https://github.com/maurycyw/StaggeredGridView), and I have it working mostly as expected, except I'm having an issue trying to get the selector to draw on top.

I've tried using mGridView.setDrawSelectorOnTop( true ); and android:drawSelectorOnTop="true" in the layout, but no success yet. Anyone happen to have solved this problem, or know if it's not possible with the library in its current state?

도움이 되었습니까?

해결책

Etsy's StaggeredGrid frustratingly doesn't support item selector drawables. To work around this, set the selector on the GridView item, not the GridView itself.

In my current project, I wrap the GridView item in a FrameLayout, because a FrameLayout has an android:foreground attribute:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:foreground="?android:attr/selectableItemBackground">

    <!-- Your item layout goes here. -->

</FrameLayout>

?android:attr/selectableItemBackground gives you the standard blue highlight. If you want, you can use your own state list drawable instead.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top