向安卓高手真诚请教,如何实现单击app后,不出现活动界面的这种效果呢?

https://pan.baidu.com/s/1EWhY...
俺的描述:这是从网上找的一个亮度控制器app.单击app后,很神奇的不出现主活动界面,取而代之的是一条通知.单击通知后,通知消失,出现设置界面.退出通知则会退出app,就像一切都没发生过一样.俺很想知道这种效果是怎么做到的,是把活动隐藏了吗???真诚希望有安卓大佬能够不吝指教一下!!

阅读 1.6k
1 个回答

可以用透明背景,android 内置有三个透明主题(主题文件路径 sdk路径下\platforms\android-版本\data\res\values\themes.xml

<!-- Theme for translucent activities (on API level 10 and lower). That is, windows
     that allow you to see through them to the windows behind.  This sets up the translucent
     flag and appropriate animations for your windows.  -->
Theme.Translucent
<!-- Variant of {@link #Theme_Translucent} with no title bar -->
Theme.Translucent.NoTitleBar
<!-- Variant of {@link #Theme_Translucent} that has no title bar and
     no status bar -->
Theme.Translucent.NoTitleBar.Fullscreen

反编译你那个 APP 可以发现它用的是前两个透明主题

还可以用这个,直接不显示 UI 界面,但必须在 onResume 结束前 finish()

<!-- Default theme for activities that don't actually display a UI; that
     is, they finish themselves before being resumed.  -->
Theme.NoDisplay
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题