I am adding the LinearLayout(child view) to another LinearLayout(parentview) programatically here I want to set the position of child view to center_horizontal. How to do that? please can somebody help me.
code
LinearLayout linearLayoutstate = new LinearLayout(this);
linearLayoutstate.setOrientation(LinearLayout.HORIZONTAL);
TextView stateTitletv = new TextView(this);
stateTitletv.setText("tv1");
TextView state_valuetv = new TextView(this);
state_valuetv.setText("tv2");
linearLayoutstate.addView(stateTitletv);
linearLayoutstate.addView(state_valuetv);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT,Gravity.CENTER_HORIZONTAL);
LL_SelectedFilters.addView(linearLayoutstate,layoutParams);
Use this a minor change:::