Rectangle 27 0

android Add a button within a ScrollView?


ScrollView scrollView = new ScrollView(this);
scrollView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));
scroll.addView(mLinearLayout);
setContentView(scroll);

Could you please post the XML where you defined the LinearLayout "R.id.linear1"?

I am confused can you show me how to do it?

I will post it and what you suggested did not work either :/

You should place your LinearLayout inside the ScrollView, because ScrollView is a container and its children are scrollable. Also, set the ScrollView as the activity's content view and define its layout params.

Note