From 48f172fc9e9a464ee220afd2a82b719ec5b984e9 Mon Sep 17 00:00:00 2001 From: saqura Date: Mon, 26 Oct 2015 00:59:32 +0100 Subject: Reset the margins manually after rotating --- .../java/eu/siacs/conversations/utils/UIHelper.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/main/java/eu/siacs/conversations/utils') diff --git a/src/main/java/eu/siacs/conversations/utils/UIHelper.java b/src/main/java/eu/siacs/conversations/utils/UIHelper.java index cac23f077..8a73d35fb 100644 --- a/src/main/java/eu/siacs/conversations/utils/UIHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/UIHelper.java @@ -3,7 +3,11 @@ package eu.siacs.conversations.utils; import android.content.Context; import android.text.format.DateFormat; import android.text.format.DateUtils; +import android.util.DisplayMetrics; import android.util.Pair; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; import java.util.ArrayList; import java.util.Arrays; @@ -261,4 +265,21 @@ public class UIHelper { body = body.replace("?","").replace("¿",""); return LOCATION_QUESTIONS.contains(body); } + + public static void resetChildMargins(LinearLayout view) { + int childCount = view.getChildCount(); + for (int i = 0; i < childCount; i++) { + UIHelper.resetMargins(view.getChildAt(i)); + } + } + + private static void resetMargins(View view) { + LinearLayout.MarginLayoutParams marginLayoutParams = new LinearLayout.MarginLayoutParams(view.getLayoutParams()); + marginLayoutParams.setMargins(view.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_horizontal_margin), + view.getResources().getDimensionPixelSize(R.dimen.activity_vertical_margin)); + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(marginLayoutParams); + view.setLayoutParams(layoutParams); + } } -- cgit v1.2.3