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.
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))
}
}
}
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