1

I startActivity from BottomSheetDialogFragment.

But when I finish the Activity, the BottomSheetDialogFragment is blinking.

My case is like this one BottomSheetDialog background blinking

But there is no solution.

Here is my screen shot

The code is simple and basic.

MainActivity.class

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val bottomSheetFragment = BottomSheetFragment()

        button.setOnClickListener {

            bottomSheetFragment.show(supportFragmentManager, "")
        }
    }
}

BottomSheetFragment.class

class BottomSheetFragment: BottomSheetDialogFragment() {

    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        return inflater.inflate(R.layout.fragment_bottom_sheet, container, false)
    }

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)

        button.setOnClickListener {

            startActivity(Intent(context!!, Test2Activity::class.java))
        }
    }
}
GHH
  • 1,713
  • 1
  • 8
  • 21

1 Answers1

0

Your Bottom sheet is not Blinking. its the effect of activity when you get back to MainActivity. in your MainActivity Please implement overridePendingTransition before onCreate()

overridePendingTransition(0,0) // due to this default effect will remove

Vikas
  • 432
  • 4
  • 17
  • I add ` override fun overridePendingTransition(enterAnim: Int, exitAnim: Int) { overridePendingTransition(0,0) }` in `MainActivity`, but not works. – GHH Sep 11 '20 at 01:24