set View Layout Parameters - Android User Interface

Android examples for User Interface:Layout

Description

set View Layout Parameters

Demo Code


//package com.java2s;

import android.graphics.Point;

import android.view.Display;

import android.view.View;

import android.widget.RelativeLayout.LayoutParams;

public class Main {
    public static void setLayoutParams(View cover, Display display) {
        Point size = getDisplaySize(display);
        int width = size.x;
        int height = size.y;

        cover.setLayoutParams(new LayoutParams(width, height));
        cover.setY((float) width);
    }//from w w w  .  j  a  v a 2 s.  co  m

    public static Point getDisplaySize(Display display) {
        Point size = new Point();
        display.getSize(size);
        return size;
    }
}

Related Tutorials