set View Layout Y - Android User Interface

Android examples for User Interface:Layout

Description

set View Layout Y

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup.MarginLayoutParams;

import android.widget.RelativeLayout;

public class Main {
    public static void setLayoutY(View view, int y) {
        MarginLayoutParams margin = new MarginLayoutParams(
                view.getLayoutParams());
        margin.setMargins(margin.leftMargin, y, margin.rightMargin, y
                + margin.height);//from   w w  w.  j a  v a 2 s . c  om
        RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
                margin);
        view.setLayoutParams(layoutParams);
    }
}

Related Tutorials