Search code examples
javaandroidandroid-layoutimagebuttonandroid-tablayout

Can't get ripple effect on ImageButton in RelativeLayout with TabLayout


ImageButton works in other layouts but for TabLayout its not working. I tried to overlay my button with CardView but it doesn't help.

<RelativeLayout
    android:id="@+id/rl_tab_container"
    android:layout_width="match_parent"
    android:layout_height="@dimen/standard_bar_height"
    >

    <android.support.design.widget.TabLayout
        android:id="@+id/tabs_dict"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:tabGravity="center"
        app:tabSelectedTextColor="@color/colorBlack87"
        app:tabTextColor="@color/colorBlack54"
        app:tabIndicatorColor="@color/colorBlack87"
        android:background="@color/colorPrimary"
        />

    <ImageButton
        android:id="@+id/button_delete_all_curr_dict"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:src="@drawable/ic_delete"
        android:layout_alignParentEnd="true"
        android:layout_centerVertical="true"
        android:layout_marginEnd="8dp"
        android:background="?attr/selectableItemBackgroundBorderless"
        />
</RelativeLayout>

Solution

  • Try this on your ImageButton

    android:clickable="true"
    android:foreground="?attr/selectableItemBackground"