[Android] Keep a stable layout when hiding the navigation bar
Martin Storsjö
git at videolan.org
Mon Jul 29 20:52:51 CEST 2013
vlc-ports/android | branch: master | Martin Storsjö <martin at martin.st> | Sun Jul 28 22:29:26 2013 +0300| [79e8aa3cd21dd9208a2419f4aa0017b1e6476be3] | committer: Martin Storsjö
Keep a stable layout when hiding the navigation bar
By adding the SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION and
SYSTEM_UI_FLAG_LAYOUT_STABLE flags, the activity can be laid out as if
the navigation bar was hidden even when it isn't, avoiding moving the
video when the UI disappears.
This requires setting the fitsSystemWindows="true" parameter for views
that still should be laid out as if the navigation bar was there. That
is, the video surface is laid out to cover the whole screen (under the
navigation bar), while the UI on top gets padding enough to not be
obscured by the navigation bar.
Signed-off-by: Martin Storsjö <martin at martin.st>
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=79e8aa3cd21dd9208a2419f4aa0017b1e6476be3
---
vlc-android/res/layout/player.xml | 7 +++++++
.../src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 7 +++++--
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/vlc-android/res/layout/player.xml b/vlc-android/res/layout/player.xml
index 9010677..b00ef6b 100644
--- a/vlc-android/res/layout/player.xml
+++ b/vlc-android/res/layout/player.xml
@@ -7,6 +7,7 @@
<!-- the double FrameLayout is necessary here to do cropping on the right
(which requires the surface not be centered), while keeping the result centered -->
<FrameLayout
+ android:fitsSystemWindows="false"
android:layout_width="match_parent"
android:layout_height="match_parent" >
@@ -25,6 +26,11 @@
</FrameLayout>
</FrameLayout>
+ <RelativeLayout
+ android:fitsSystemWindows="true"
+ android:layout_height="match_parent"
+ android:layout_width="match_parent">
+
<TextView
android:id="@+id/player_overlay_info"
android:layout_width="wrap_content"
@@ -205,4 +211,5 @@
android:background="@drawable/ic_lock" />
</LinearLayout>
+ </RelativeLayout>
</RelativeLayout>
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 67c12f0..2d89f36 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -1343,11 +1343,14 @@ public class VideoPlayerActivity extends Activity implements IVideoPlayer {
private void dimStatusBar(boolean dim) {
if (!Util.isHoneycombOrLater() || !Util.hasNavBar())
return;
+ int layout = 0;
+ if (!Util.hasCombBar() && Util.isJellyBeanOrLater())
+ layout = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
mSurface.setSystemUiVisibility(
- dim ? (Util.hasCombBar()
+ (dim ? (Util.hasCombBar()
? View.SYSTEM_UI_FLAG_LOW_PROFILE
: View.SYSTEM_UI_FLAG_HIDE_NAVIGATION)
- : View.SYSTEM_UI_FLAG_VISIBLE);
+ : View.SYSTEM_UI_FLAG_VISIBLE) | layout);
}
private void updateOverlayPausePlay() {
More information about the Android
mailing list