Search code examples
androidandroid-tvandroid-fullscreen

How to use AppCompatActivity in Android TV on full screen?


I have written a game for the android platform. The game is currently in beta stage at the store. To see how it looks on a device you can downloaded it from here: Brainy: Play to learn!

Now I'm trying to port this game to Android TV platform, but for some reason when the game is run on the TV it's not uses the whole screen space, it runs in a square in the middle of the screen. It looks like that in the better case:

enter image description here

And like that in the worst case:

enter image description here

Now for all activities in my application I use the AppCompatActivity which means that the Theme for those activities should be or inherite from Theme.AppCompat. Which I think is the problem in this case.

Because Activities for tv should have the Theme.Leanback.

Does someone maybe dealt with this situation here and knows how to go about it. I tried already all the combinations of themes for the app and the activities that I could think of, but so far can't find a solution.


Solution

  • Finally I managed to solved this issue, the problem was the theme I used for the activities. I was using Theme.AppCompat.Light.NoActionBar.FullScreen as the base theme for all my activities.

    Turns out that using the FullScreen theme on the TV will actually show the application in a square like in the screenshots above and not in full screen.

    Changing this base theme to Theme.AppCompat.Light.NoActionBar solved the issue. Now the application is displayed on full screen.