androidandroid-layoutrippledrawable

How to make a ripple effect over a linear layout, without overriding the background color on its children?


I have a LinearLayout that looks like this. enter image description here

I want each row to be clickable. The LinearLayout code for a row looks like this:

    <LinearLayout
        style="@style/home_menu_item_container"
        android:id="@+id/home_menu_acronyms_button"
        >
        <ImageView
            style="@style/home_menu_item_left"
            android:background="@color/greyLight"

            />
        <TextView
            style="@style/home_menu_item_right"
            android:text="@string/home_menu_option_2"
            android:background="@color/grey"
            />
    </LinearLayout>

How can I add a ripple effect that expands over the entire row (parent) - not just one child view in the row? The tricky part here is to let the ripple go over the two colored row.


Solution

  • It is a little bit complicated for that what you need but I don't think there is another way,...
    You need to put your ImageView's into a ListView so that every ImageView is a ListItem and then you can set the ripple but you also need to set drawSelectorOnTop="true" otherwise it won't work correctly