【发布时间】:2017-11-07 13:07:57
【问题描述】:
我正在尝试获取StatusBarView(我需要它用于活动共享元素过渡动画)。
我在我的活动中使用以下代码:
View decorView = getWindow().getDecorView();
View statusBar = decorView.findViewById(android.R.id.statusBarBackground);
但statusBar 始终是null。
我在onCreate() 和onResume() 之后尝试了这段代码 - 没有效果。
怎么了?
【问题讨论】:
-
@IntelliJAmiya nop,您可以使用它获得一些视图,例如 getWindow().getDecorView().findViewById(android.R.id.content) 从当前活动返回根视图
-
@FarshidABZ 好吧好吧
-
您无法从 android R 文件中获取状态栏视图。为什么要得到它?
-
@FarshidABZ,好吧,看看这个问题并接受答案stackoverflow.com/questions/26600263/…
-
@T.Vert 哇,我要测试一下