set View Absolute Position And Size - Android User Interface

Android examples for User Interface:View Position

Description

set View Absolute Position And Size

Demo Code


//package com.java2s;
import android.view.View;
import android.widget.FrameLayout.LayoutParams;

public class Main {
    public static void setAbsolutePositionAndSize(View v, int x, int y,
            int w, int h) {
        LayoutParams lp = (LayoutParams) v.getLayoutParams();
        lp.leftMargin = x;/*from   ww w .j a v  a2s. c o m*/
        lp.topMargin = y;
        lp.width = w;
        lp.height = h;
        v.setLayoutParams(lp);
    }
}

Related Tutorials