Android - Programmatically Specify Height And Width Of New Scrollview
I'm new to Android and I'm working through a tutorial on programmatically creating a layout instead of doing it through the xml, I'm sorta stuck can someone advise please. So I ha
Solution 1:
Try setting it up like this:
home_scroll.setLayoutParams(new ViewGroup.LayoutParams(480, 800));
home_scroll.addView(home_linear, newLayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
The linearlayout should now fill the scrollview.
Solution 2:
Did you try doing something like
home_scroll.setLayoutParams(..,..);
you can find these here
setLayoutParams(ViewGroup.LayoutParams params)
Set the layout parameters associated withthis view.
Solution 3:
Simple way you can give dinamic width and height:-
LayoutParamslayout=newLayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layout.setMargins(screenWidth / 5, screenHeight - cardHeight - 30, 0, 0);
tvConftxt.setLayoutParams(layout);
Post a Comment for "Android - Programmatically Specify Height And Width Of New Scrollview"