I habe eine Aktivität, die eine Scroll mit einem vertikalen Linearlayout aufweist, die zwei Fragmente haben, die PreferenceFragment Fälle sind wie in der folgenden Layout-Datei dargestellt:Scroll> Linearlayout> PreferenceFragment Null Höhe
<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>
Das Problem besteht darin, dass die beiden Fragmente nur mit ihrem PreferenceCategory-Titel angezeigt werden und das tatsächliche Fragment-UI null Höhe hat und nicht sichtbar ist. Seltsamerweise ist es möglich, jedes Fragment einzeln zu scrollen und das UI des fehlenden Fragments zu sehen. Es ist, als ob jedes Fragment in einer ScrollView ist.
Ich erwartete, dass die beiden Fragmente so groß waren, dass sie ihren Inhalt umschlossen, und es gab einen einzigen vertikalen Schieberegler, um das LinearLayout zu scrollen, das beide Fragmente enthielt.
Falls relevant, erweitern die beiden Fragmente android.preference.PreferenceFragment und definieren ihr Layout nicht in einer Layoutdatei. Stattdessen laden sie ihre Präferenz-UI wie folgt:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.pref_notification);
}
TIA für Ihre Hilfe.
eine Lösung gefunden? – Ewoks