Get inflater from Context
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = LayoutInflater.from(context);
Set height and width of Custom view programetically
view.setLayoutParams(new LayoutParams(width, height));