get layout parameters for long table row name TextView - Android User Interface

Android examples for User Interface:TextView

Description

get layout parameters for long table row name TextView

Demo Code


//package com.java2s;
import android.content.Context;
import android.util.TypedValue;

import android.widget.RelativeLayout;

public class Main {
    private static Context sContext;

    /**// w  w  w .  ja  v a2s  .  c  o  m
     * @return layout parameters for long table row name text views.
     */
    public static RelativeLayout.LayoutParams getRelativeNameLong() {
        return new RelativeLayout.LayoutParams(calcPx(80), calcPx(30));
    }

    /**
     * Calculates the number of pixels corresponding to the given device independent pixels for the current device.
     * 
     * @param aDp
     *            The number of device independent pixels to transform.
     * @return the number of pixels that corresponds to the given value.
     */
    public static int calcPx(final int aDp) {
        return Math.round(TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP, aDp, sContext.getResources()
                        .getDisplayMetrics()));
    }
}

Related Tutorials