@Test public void shouldBeSameHeightAfterSyncHeight() throws Exception { final View leftView = new View(LMISApp.getContext()); final View rightView = new View(LMISApp.getContext()); leftView.setLayoutParams(new ViewGroup.LayoutParams(1,100)); rightView.setLayoutParams(new ViewGroup.LayoutParams(1,200)); ViewUtil.syncViewHeight(leftView, rightView); assertEquals(leftView.getHeight(),rightView.getHeight()); }
public static void syncViewHeight(final View leftView, final View rightView) { int leftHeight = leftView.getHeight(); int rightHeight = rightView.getHeight(); if (leftHeight > rightHeight) { ViewGroup.LayoutParams layoutParams = rightView.getLayoutParams(); layoutParams.height = leftHeight; rightView.setLayoutParams(layoutParams); } else { ViewGroup.LayoutParams layoutParams = leftView.getLayoutParams(); layoutParams.height = rightHeight; leftView.setLayoutParams(layoutParams); if (rightView.getLayoutParams() instanceof FrameLayout.LayoutParams) { rightView.setLayoutParams(new FrameLayout.LayoutParams(layoutParams.width, layoutParams.height)); } else { rightView.setLayoutParams(layoutParams); } } }
ViewUtil { public static void syncViewHeight(final View leftView, final View rightView) { int leftHeight = leftView.getHeight(); int rightHeight = rightView.getHeight(); if (leftHeight > rightHeight) { ViewGroup.LayoutParams layoutParams = rightView.getLayoutParams(); layoutParams.height = leftHeight; rightView.setLayoutParams(layoutParams); } else { ViewGroup.LayoutParams layoutParams = leftView.getLayoutParams(); layoutParams.height = rightHeight; leftView.setLayoutParams(layoutParams); if (rightView.getLayoutParams() instanceof FrameLayout.LayoutParams) { rightView.setLayoutParams(new FrameLayout.LayoutParams(layoutParams.width, layoutParams.height)); } else { rightView.setLayoutParams(layoutParams); } } } }
ViewUtil { public static void syncViewHeight(final View leftView, final View rightView) { int leftHeight = leftView.getHeight(); int rightHeight = rightView.getHeight(); if (leftHeight > rightHeight) { ViewGroup.LayoutParams layoutParams = rightView.getLayoutParams(); layoutParams.height = leftHeight; rightView.setLayoutParams(layoutParams); } else { ViewGroup.LayoutParams layoutParams = leftView.getLayoutParams(); layoutParams.height = rightHeight; leftView.setLayoutParams(layoutParams); if (rightView.getLayoutParams() instanceof FrameLayout.LayoutParams) { rightView.setLayoutParams(new FrameLayout.LayoutParams(layoutParams.width, layoutParams.height)); } else { rightView.setLayoutParams(layoutParams); } } } private  ViewUtil(); }
ViewUtil { public static void syncViewHeight(final View leftView, final View rightView) { int leftHeight = leftView.getHeight(); int rightHeight = rightView.getHeight(); if (leftHeight > rightHeight) { ViewGroup.LayoutParams layoutParams = rightView.getLayoutParams(); layoutParams.height = leftHeight; rightView.setLayoutParams(layoutParams); } else { ViewGroup.LayoutParams layoutParams = leftView.getLayoutParams(); layoutParams.height = rightHeight; leftView.setLayoutParams(layoutParams); if (rightView.getLayoutParams() instanceof FrameLayout.LayoutParams) { rightView.setLayoutParams(new FrameLayout.LayoutParams(layoutParams.width, layoutParams.height)); } else { rightView.setLayoutParams(layoutParams); } } } private  ViewUtil(); static void syncViewHeight(final View leftView, final View rightView); static boolean checkEditTextEmpty(EditText editText); }
ViewUtil { public static void syncViewHeight(final View leftView, final View rightView) { int leftHeight = leftView.getHeight(); int rightHeight = rightView.getHeight(); if (leftHeight > rightHeight) { ViewGroup.LayoutParams layoutParams = rightView.getLayoutParams(); layoutParams.height = leftHeight; rightView.setLayoutParams(layoutParams); } else { ViewGroup.LayoutParams layoutParams = leftView.getLayoutParams(); layoutParams.height = rightHeight; leftView.setLayoutParams(layoutParams); if (rightView.getLayoutParams() instanceof FrameLayout.LayoutParams) { rightView.setLayoutParams(new FrameLayout.LayoutParams(layoutParams.width, layoutParams.height)); } else { rightView.setLayoutParams(layoutParams); } } } private  ViewUtil(); static void syncViewHeight(final View leftView, final View rightView); static boolean checkEditTextEmpty(EditText editText);  }