I have an activity that has a ScrollView with a vertical LinearLayout that has two fragments that are PreferenceFragment instances as shown in the following layout file:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
android:layout_width="match_parent"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.foo.app.SettingsActivity">
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.foo.app.SettingsFragment"
android:id="@+id/fragment_settings"/>
<fragment
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:name="com.foo.app.NotificationSettingsFragment"
android:id="@+id/fragment_notification_settings"/>
</LinearLayout>
The problem is that the two fragments show up with just their PreferenceCategory title and the actual fragment UI is zero height and not visible. Oddly, it is possible to scroll each fragment individually and see the missing fragment UI. It is as if each Fragment is inside a ScrollView.
What I expected was for the two fragments to be sized to wrap their content and there be a single vertical slider to scroll the LinearLayout containing both fragments.
In case it is relevant, the two fragments extends android.preference.PreferenceFragment and do not define their layout in a layout file. Instead they load their Preference UI as follows:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.pref_notification);
}
TIA for your help.