Skip to content
Snippets Groups Projects
LayoutUtils.java 855 B
Newer Older
package org.briarproject.android.util;

import static android.content.Context.WINDOW_SERVICE;
import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

public class LayoutUtils {

	public static int getPadding(Context ctx) {
akwizgran's avatar
akwizgran committed
		DisplayMetrics metrics = getDisplayMetrics(ctx);
		int percent = Math.max(metrics.widthPixels, metrics.heightPixels) / 100;
		return percent + 7;
akwizgran's avatar
akwizgran committed
	public static int getLargeItemPadding(Context ctx) {
		DisplayMetrics metrics = getDisplayMetrics(ctx);
		return Math.min(metrics.widthPixels, metrics.heightPixels) / 4;
	}

	private static DisplayMetrics getDisplayMetrics(Context ctx) {
		DisplayMetrics metrics = new DisplayMetrics();
		WindowManager wm = (WindowManager) ctx.getSystemService(WINDOW_SERVICE);
		wm.getDefaultDisplay().getMetrics(metrics);
akwizgran's avatar
akwizgran committed
		return metrics;