Skip to content

Commit

Permalink
fix get aspect ratio to get full screen (including virtual button)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferdian-s committed Jun 21, 2018
1 parent 9183095 commit e01a0b8
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Point;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Rect;
Expand All @@ -42,7 +43,9 @@
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.Display;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.widget.FrameLayout;

import java.lang.annotation.Retention;
Expand Down Expand Up @@ -143,9 +146,13 @@ public CameraView(Context context, AttributeSet attrs, int defStyleAttr) {
@Override
public void onGlobalLayout() {
getViewTreeObserver().removeOnGlobalLayoutListener(this);
DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
deviceWidth = displayMetrics.widthPixels;
deviceHeight = displayMetrics.heightPixels;
WindowManager wm = ((WindowManager)
getContext().getSystemService(Context.WINDOW_SERVICE));
Display display = wm.getDefaultDisplay();
Point screenSize = new Point();
display.getRealSize(screenSize);
deviceWidth = screenSize.x;
deviceHeight = screenSize.y;
setAspectRatio(AspectRatio.of(deviceHeight, deviceWidth));
}
});
Expand Down

0 comments on commit e01a0b8

Please sign in to comment.