I'm trying to make ripple effect in ImageView inside Toolbar using
android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
But when I run the app, the output is looks like ?attr/selectableItemBackground
. Then I'm trying to change Toolbar
to RelativeLayout
. It's work, but I need to use Toolbar instead of RelativeLayout.
I'm also try it using android:background="?attr/selectableItemBackgroundBorderless"
. But there's no ripple effect if I use android:background
. Here's my code:
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGrey"
tools:context=".User.BottomNavigationView.Student.StudentDetailActivity">
<com.google.android.material.appbar.AppBarLayout
android:id="@ id/student_detail_app_bar_layout"
android:layout_width="match_parent"
android:layout_height="300dp"
android:fitsSystemWindows="true"
android:theme="@style/ActionBarTextColor">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@ id/student_detail_collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="@color/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:title="Detail Siswa">
<ImageView
android:id="@ id/student_detail_profile_picture_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/img1"
app:layout_collapseMode="parallax" />
<androidx.appcompat.widget.Toolbar
android:id="@ id/student_detail_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:actionBarSize"
app:layout_collapseMode="pin">
<ImageView
android:id="@ id/student_detail_back_button_image_view"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_centerVertical="true"
android:layout_marginEnd="32dp"
android:clickable="true"
android:foreground="?attr/selectableItemBackgroundBorderless"
android:padding="3dp"
android:src="@drawable/general_back_button"
app:tint="@color/colorPrimaryIcon" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorGrey"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
I want to use ?attr/selectableItemBackgroundBorderless
or circular ripple effect
in ImageView inside Toolbar. How can I do that?
CodePudding user response:
Add focusable true it will work
android:focusable="true"
Below I have added clickable and focusable code
android:foreground="?attr/selectableItemBackgroundBorderless"
android:clickable="true"
android:focusable="true"