Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BlurView doesn't provide dynamic blur for BottomSheetDialog #217

Closed
krupalivaghasiya24 opened this issue Jul 25, 2024 · 1 comment
Closed

Comments

@krupalivaghasiya24
Copy link

krupalivaghasiya24 commented Jul 25, 2024

Please include:

  1. Library version : 2.0.3
  2. Device and OS version : 34
  3. Detailed steps to reproduce the issue : open bottom sheet dialog onclick of any view & you can see only transparent effect can't see blur effect
  4. XML layout and code for BlurView setup

dialog_notification_filter.xml

<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="@dimen/sixteen_sdp"
android:paddingBottom="@dimen/_80sdp">

<eightbitlab.com.blurview.BlurView
    android:id="@+id/blurView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:blurOverlayColor="#4D111111"
    android:background="@drawable/bg_n_filter"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rvBottom"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            tools:listitem="@layout/layout_notification_filter" />

    </LinearLayout>

</eightbitlab.com.blurview.BlurView>

</androidx.constraintlayout.widget.ConstraintLayout>

Kotlin code :

lateinit var dialogNotificationFilterBinding: DialogNotificationFilterBinding
lateinit var bottomSheetDialog: BottomSheetDialog

private fun createNotificationFilterDialog() {

    bottomSheetDialog = BottomSheetDialog(requireContext(), R.style.BottomSheetDialogTransStyle)
    dialogNotificationFilterBinding =
        DialogNotificationFilterBinding.inflate(LayoutInflater.from(activity))
    bottomSheetDialog.setContentView(dialogNotificationFilterBinding.root)
    bottomSheetDialog.window!!.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))

    bottomSheetDialog.setCanceledOnTouchOutside(true)
    bottomSheetDialog.setCancelable(true)

    addDataInFilterList()
    
    val mBottomAdapter =
        NotificationFilterAdapter(
            viewModel.filterList,
            requireContext(),
            fType
        )
        { position, view ->
            if (fType == 1) {
                binding.tvFilTime.text = viewModel.filterList[position]?.text ?: ""
            }

            if (fType == 2) {
                binding.tvFilType.text = viewModel.filterList[position]?.text ?: ""
            }

            if (fType == 3) {
                binding.tvFilStatus.text = viewModel.filterList[position]?.text ?: ""
            }
            bottomSheetDialog.dismiss()
        }
    dialogNotificationFilterBinding.rvBottom.apply {
        this.adapter = mBottomAdapter
        this.layoutManager = LinearLayoutManager(requireContext())
        val itemDecoration = DividerItemDecoration(this.context, DividerItemDecoration.VERTICAL)
        itemDecoration.setDrawable(
            ContextCompat.getDrawable(
                requireContext(),
                R.drawable.bg_divider
            )!!
        )
        addItemDecoration(itemDecoration)
    }

    try {
        bottomSheetDialog.show()
    } catch (ignored: Exception) {
    }

    val radius = 12f
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
        dialogNotificationFilterBinding.blurView.setupWith(
            dialogNotificationFilterBinding.main,
            RenderEffectBlur()
        ).setBlurRadius(radius)
            .setBlurAutoUpdate(true)
    }
}

style

<style name="BottomSheetDialogTransStyle" parent="Theme.Design.Light.BottomSheetDialog"> @style/bottomSheetTransperentBackground </style>
<style name="bottomSheetTransperentBackground" parent="Widget.Design.BottomSheet.Modal">
    <item name="android:background">@color/transparent</item>
</style>

Let me know if you need more details

@Dimezis
Copy link
Owner

Dimezis commented Jul 25, 2024

Duplicate of #216

@Dimezis Dimezis marked this as a duplicate of #216 Jul 25, 2024
@Dimezis Dimezis closed this as completed Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants