【问题标题】:Android BottomSheetDialogFragment blinkingAndroid BottomSheetDialogFragment 闪烁
【发布时间】:2020-12-28 12:10:03
【问题描述】:

我从 BottomSheetDialogFragment 开始活动。

但是当我完成 Activity 时,BottomSheetDialogFragment 正在闪烁。

我的情况是这样的BottomSheetDialog background blinking

但是没有解决办法。

Here is my screen shot

代码简单基本。

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

【问题讨论】:

  • 启动活动时关闭底部表格
  • @Vikas 我不想忽略它。我想在活动完成后立即查看底部表。

标签: android kotlin bottom-sheet android-bottomsheetdialog bottomsheetdialogfragment


【解决方案1】:

您的底页没有闪烁。当您返回 MainActivity 时,它是活动的效果。 在您的 MainActivity 请在 onCreate() 之前实现 overridePendingTransition

overridePendingTransition(0,0) // 由于这个默认效果会被移除

【讨论】:

  • 我在MainActivity 中添加了` override fun overridePendingTransition(enterAnim: Int, exitAnim: Int) { overridePendingTransition(0,0) }`,但不起作用。
猜你喜欢
  • 2020-03-30
  • 1970-01-01
  • 1970-01-01
  • 2013-01-21
  • 2018-01-30
  • 1970-01-01
  • 2015-10-28
  • 2012-03-12
  • 1970-01-01
相关资源
最近更新 更多