简体   繁体   English

应用如何在Android活动中临时显示全屏动画?

[英]How can an app temporarily display a full screen animation in an Android activity?

Similar questions have been asked before, but I couldn't find an answer to how to make one element full screen. 之前已经问过类似的问题,但我找不到如何将一个元素全屏制作的答案。 I would like to temporarily display a full-screen animation in my Android app without moving to a new Activity. 我想暂时在我的Android应用中显示全屏动画,而无需转移到新的活动。 The app has an ImageView for the animation and I show the animation with: 该应用程序有一个动画的ImageView,我用以下方式显示动画:

image.setBackground(animation);

and make it "go away" with: 并使其“消失”:

image.setBackground(null);

For the ImageView, both android:layout_width and android:layout_height are set to "match_parent". 对于ImageView,android:layout_width和android:layout_height都设置为“match_parent”。 It works, but of course the animation doesn't include the title bar at the top or the icons at the bottom. 它有效,但当然动画不包括顶部的标题栏或底部的图标。 I even tried setting the layout_marginTop and layout_marginBottom to negative values, but I know that can't be the best solution for every device or orientation which may run this app. 我甚至尝试将layout_marginTop和layout_marginBottom设置为负值,但我知道这对于可能运行此应用的每个设备或方向都不是最佳解决方案。

How can I change the size of the ImageView to full screen so I can show it as needed, or is there a better way to do what I want? 如何将ImageView的大小更改为全屏,以便我可以根据需要显示它,还是有更好的方法来做我想要的?

Duplicate of Fullscreen Activity in Android? Android中全屏活动重复 .

Just set the right flags and dismiss the activity when it's finished its animation. 只需设置正确的标志,并在完成动画时关闭活动。

Your ImageView is stuck inside the bounds of your Activity. 您的ImageView卡在您的Activity范围内。 And I don't think there is a way for you to change your Activity to be full screen sometimes but not others. 而且我认为有时候你没有办法将你的活动改为全屏而不是其他人。

If you want your Activity to be fullscreen always you can set the theme in the manifest like this: 如果您希望您的活动始终全屏,您可以在清单中设置主题,如下所示:

<activity
    android:name="com.your.package.name.YourActivity"
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>

Combine both answers. 结合两个答案。 Create a new activity to play your animation and set the theme of your animation activity to fullscreen. 创建一个新活动以播放动画,并将动画活动的主题设置为全屏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM