0

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. The app has an ImageView for the animation and I show the animation with:

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". 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.

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?

ScottyB
  • 2,167
  • 1
  • 30
  • 46

3 Answers3

1

Duplicate of Fullscreen Activity in Android?.

Just set the right flags and dismiss the activity when it's finished its animation.

Community
  • 1
  • 1
indivisible
  • 4,892
  • 4
  • 31
  • 50
  • I'm hoping for a solution that stays within the existing activity, and I don't think that does it. – ScottyB Feb 18 '14 at 14:51
  • @ScottBowers I think you are out of luck , AFAIK once you've painted your views there is no way to go back and change the theme of your Activity. You have to start a new one if you want to change it. – FoamyGuy Feb 18 '14 at 14:53
  • 2
    Why would it need to stay in the same Activity? If it's just an animation then surely there'd be no issues like passing values or params around making a new Activity harder to implement. Can you elaborate on what part of your design limits you to a single activity? – indivisible Feb 18 '14 at 14:56
  • It's really a timing thing. I would like the animation to start at a very precise time, and I thought it would be better to avoid the delay of moving to a new Activity, especially since I would be going right back after it was finished. I suppose I could move to a new activity a second or so before I need it to play, then start it when needed once there. Thanks for your advice. – ScottyB Feb 18 '14 at 15:03
  • Decided to make the whole activity full-screen, which is ok for my purposes. Thanks. – ScottyB Feb 18 '14 at 18:57
1

Your ImageView is stuck inside the bounds of your 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>
FoamyGuy
  • 46,603
  • 18
  • 125
  • 156
  • Could I edit the theme to include a full-screen (with null background) ImageView? If so, how do I do that or should I ask a new question? – ScottyB Feb 18 '14 at 14:53
  • No, the theme applies to the entire Activity, not just a single view within it. – FoamyGuy Feb 18 '14 at 14:54
0

Combine both answers. Create a new activity to play your animation and set the theme of your animation activity to fullscreen.

Barışcan Kayaoğlu
  • 1,294
  • 3
  • 14
  • 35