I'm trying to add Fragment to a ScrollView, but I can't find a way to specify layout params that works.
Fragment is created like this:
FragmentManager supportFragmentManager = getActivity().getSupportFragmentManager();
SomeFragment fragment = new SomeFragment();
FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
fragmentTransaction.add(R.id.scrollView, fragment).commit();
This is the scrollView:
<ScrollView
android:id="@+id/scrollView"
android:layout_width="match_parent"
android:layout_height="25dp"
android:scrollbars="none"
android:background="#0000FF">
The fragments layout is like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="25dp">
</RelativeLayout>
But it's not shown correct. The blue color is the background of the scrollView but the height is set to be 25dp for both the content of the Fragment and the scrollView.
How could I fix this so the Fragment uses all 25dp (I can measure it doesn't) of the scrollView?
I have tried with code similar to this, at multiple places:
ScrollView.LayoutParams params = new ScrollView.LayoutParams(ScrollView.LayoutParams.MATCH_PARENT, ScrollView.LayoutParams.MATCH_PARENT);
fragment.getView().setLayoutParams(params);