I want to set layout in Java code file. I use the following code to set this layout to center
        theme = db.getthemeByID(id);
        String themePath = theme.getFilepath();
        int resid = getResources().getIdentifier(themePath, "drawable", getPackageName());
        //layout for book theme
        LinearLayout LLT = new LinearLayout(context);
        LLT.setOrientation(LinearLayout.VERTICAL);
    >>>>LLT.setLayoutParams(new LayoutParams(500, 650, Gravity.CENTER_HORIZONTAL));
        LLT.setBackgroundResource(resid);   
        // add view 
        VF.addView(LLT);
I'm still getting error on this line:
LLT.setLayoutParams(new LayoutParams(500, 650, Gravity.CENTER_HORIZONTAL));
How can I do if I want to set layout to center_horizontal
 
     
     
     
    