0

I am writing a countdown timer android app. One little feature of the app is the timer is allowed to stay in picture-in-picture mode. Everything else works fine. The only problem is as what I need to display on the small window is the countdown time, so I would like the small window to be even smaller. Otherwise, there is a lot of blank space which looks ugly, like this:

timer pip

The PictureInPictureParams.Builder().setAspectRatio(rational) only allow me to change the aspect ratio but not the size. Is there other ways to further reduce the size of the small window?

Wakeman
  • 103
  • 7

1 Answers1

1

No direct answer so far. I came up with a workaround. I made the timer activity transparent by using a custom theme:

<style name="Theme.Transparent" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="android:windowIsTranslucent">true</item>
        <item name="android:windowBackground">@android:color/transparent</item>
</style>

When the activity enter picture-in-picture mode, I change the background color of the parent layout of the timer textview to transparent, and everything else to visibility.gone. The result is this:

enter image description here

Not perfect but I guess I can do with this at the moment. Please comment if you can think of any improvement to this. Thanks.

Wakeman
  • 103
  • 7