set Width For View - Android User Interface

Android examples for User Interface:View Size

Description

set Width For View

Demo Code


//package com.java2s;

import android.view.View;
import android.view.ViewGroup;

public class Main {
    public static void setWidthForView(View view, int widthInPixels) {
        ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
        layoutParams.width = widthInPixels;
        view.setLayoutParams(layoutParams);
    }//from  w w  w  .  ja va  2s .  c om
}

Related Tutorials