set View Absolute Position - Android User Interface

Android examples for User Interface:View Position

Description

set View Absolute Position

Demo Code


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

public class Main {
    public static void setAbsolutePosition(View v, int x, int y) {
        LayoutParams lp = (LayoutParams) v.getLayoutParams();
        lp.leftMargin = x;/*  www  . jav  a 2 s  . c  o m*/
        lp.topMargin = y;
        v.setLayoutParams(lp);
    }
}

Related Tutorials