code-scanner
code-scanner copied to clipboard
Ripple effect won't work when using RelativeLayout with CodeScannerView
Hello! I don't understand what's wrong.
I have ImageButton with
android:background="?attr/selectableItemBackgroundBorderless"
And this located is inside RelativeLayout. Ripple effect doesn't work!
I tried to put imagebutton to toolbar, and it works.
My layout :
<RelativeLayout 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="@android:color/transparent"
tools:context=".Screens.Scanner.ScannerActivity">
<com.budiyev.android.codescanner.CodeScannerView
android:id="@+id/scanner_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@null"
android:elevation="0dp"
android:visibility="visible"
app:autoFocusButtonColor="@android:color/white"
app:autoFocusButtonVisible="false"
app:flashButtonColor="@color/colorPrimary"
app:flashButtonVisible="false"
app:frameAspectRatioHeight="1.04"
app:frameAspectRatioWidth="0.956"
app:frameColor="@color/QrFrameColor"
app:frameCornersSize="63dp"
app:frameSize="0.5"
app:frameThickness="10dp"
app:maskColor="#77000000" />
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:background="@color/transparent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
app:elevation="0dp"
app:theme="@style/CustomActionBar">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:popupTheme="@style/ThemeOverlay.AppCompat.Dark"
app:titleTextAppearance="@style/ActionBar.nameText"></androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<ImageButton
android:id="@+id/flashBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="44dp"
android:layout_marginBottom="72dp"
android:background="?attr/selectableItemBackgroundBorderless"
app:srcCompat="@drawable/ic_flashlight" />
</RelativeLayout>
Maybe something wrong with maskColor attribute. I tried to create my own drawable with ripple effect but this doesn't work anyway
Probably the promlem is in the TextureView which is used to display preview, try ripple when preview is stopped.
Also, try to use ConstraintLayout instead of RelativeLayout.