I’m trying to create a FrameLayout programmatically as follows(this view will float on the the bottom center of a LinearLayout):
FrameLayout bottomFrameLayout = new FrameLayout(context);
bottomFrameLayout.setLayoutParams(new FrameLayout.LayoutParams(0,LayoutParams.FILL_PARENT,Gravity.CENTER | Gravity.BOTTOM));
Since I set layout_width=0dp, I would like to also set layout_weight to control the width. How can I do that?
You need to use
LinearLayout.LayoutParams (int width, int height, float weight)constructor sinceFrameLayoutis child ofLinearLayouttherefore you are setting params for child inLinearLayout.Edit: