clone Layout Parameters - Android User Interface

Android examples for User Interface:Layout

Description

clone Layout Parameters

Demo Code


//package com.java2s;

import android.widget.RelativeLayout;

public class Main {
    public static RelativeLayout.LayoutParams cloneParams(
            RelativeLayout.LayoutParams params) {
        RelativeLayout.LayoutParams copy = new RelativeLayout.LayoutParams(
                params.width, params.height);
        copy.leftMargin = params.leftMargin;
        copy.topMargin = params.topMargin;
        copy.rightMargin = params.rightMargin;
        copy.bottomMargin = params.bottomMargin;
        int[] rules = params.getRules();
        for (int i = 0; i < rules.length; i++) {
            copy.addRule(i, rules[i]);/*from  www  .j  av a  2 s.  c  om*/
        }
        //copy.setMarginStart(params.getMarginStart());
        //copy.setMarginEnd(params.getMarginEnd());

        return copy;
    }
}

Related Tutorials