How do I create a transparent Activity on Android?

前端 未结 22 2128
忘掉有多难
忘掉有多难 2020-11-21 04:43

I want to create a transparent Activity on top of another activity.

How can I achieve this?

22条回答
  •  臣服心动
    2020-11-21 05:23

    There're two ways:

    1. Using Theme.NoDisplay
    2. Using Theme.Translucent.NoTitleBar

    Using Theme.NoDisplay will still work… but only on older Android devices. On Android 6.0 and higher, using Theme.NoDisplay without calling finish() in onCreate() (or, technically, before onResume()) will crash your app. This is why the recommendation is to use Theme.Translucent.NoTitleBar, which does not suffer from this limitation.”

提交回复
热议问题