Last active
December 10, 2015 02:18
-
-
Save jgilfelt/4366555 to your computer and use it in GitHub Desktop.
Custom LinearLayout needed for fullscreen YouTube player when using SYSTEM_UI_FLAG_HIDE_NAVIGATION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.readystatesoftware.views; | |
import android.content.Context; | |
import android.graphics.Rect; | |
import android.util.AttributeSet; | |
import android.widget.LinearLayout; | |
public class FittingLinearLayout extends LinearLayout { | |
public FittingLinearLayout(Context context, AttributeSet attrs, int defStyle) { | |
super(context, attrs, defStyle); | |
} | |
public FittingLinearLayout(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
public FittingLinearLayout(Context context) { | |
super(context); | |
} | |
@Override | |
protected boolean fitSystemWindows(Rect insets) { | |
LinearLayout.LayoutParams params = ((LinearLayout.LayoutParams)this.getLayoutParams()); | |
int top = params.topMargin; | |
// lets apply any left, right or bottom margin supplied by the framework insets | |
// so the YouTubePlayerFragment controls aren't obscured when we reveal the | |
// system UI in SYSTEM_UI_FLAG_HIDE_NAVIGATION mode | |
params.setMargins(insets.left, top, insets.right, insets.bottom); | |
return super.fitSystemWindows(insets); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment