set Relative Layout Size - Android android.widget

Android examples for android.widget:RelativeLayout

Description

set Relative Layout Size

Demo Code

import android.view.ViewGroup;
import android.widget.RelativeLayout;

public class Main {

  public static void setRelativeLayoutSize(RelativeLayout relativeLayout, int screenWidth) {
    ViewGroup.LayoutParams layoutParams = null;
    try {/*w ww . j  a  va  2 s .c  o m*/
      layoutParams = relativeLayout.getLayoutParams();
    } catch (Exception e) {
      e.printStackTrace();
    }
    layoutParams.width = screenWidth;
    layoutParams.height = screenWidth;

    relativeLayout.setLayoutParams(layoutParams);

  }

}

Related Tutorials