get Layout Params - Android User Interface

Android examples for User Interface:Layout Inflater

Description

get Layout Params

Demo Code


//package com.java2s;

import android.widget.RelativeLayout.LayoutParams;

public class Main {
    public static int SCREEN_WIDTH = 800;
    public static int SCREEN_HEIGHT = 480;
    public static int SCALE_BASE_X = 800;
    public static int SCALE_BASE_Y = 480;

    public static LayoutParams getLayoutParams(int width, int height) {
        return new LayoutParams((int) (width * getScaleX()),
                (int) (height * getScaleY()));
    }/*  www  . j  a va 2  s. c o  m*/

    public static float getScaleX() {
        float scaleX = 1.0f * SCREEN_WIDTH / SCALE_BASE_X;
        return scaleX;
    }

    public static float getScaleY() {
        float scaleX = 1.0f * SCREEN_HEIGHT / SCALE_BASE_Y;
        return scaleX;
    }
}

Related Tutorials