In meiner Aktivitätslayoutdatei definiere ich eine AppBarLayout
mit einer Toolbar
darin. Dann nehme ich den Hauptinhalt dieser Activity
aus einer anderen Datei, die scrollbar sein sollte.Ein scrollbares Layout unter einer Symbolleiste einfügen
Ich kann den Inhalt der zweiten Aktivität scrollen, jedoch beim Scrollen nach unten, wird ein Teil des Layouts einfach ausgeschnitten. (Ich kann die unteren Tasten nicht sehen). Ich will nicht die Toolbar
scrollbar sein, nur den Inhalt.
activity_first:
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#FFF"
tools:context=".StartScreens.Home.HomeScreens.FirstActivity"
xmlns:android="http://schemas.android.com/apk/res/android">
<android.support.design.widget.AppBarLayout
android:id="@+id/Activity_AppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include android:id="@+id/Activity_Toolbar"
layout="@layout/toolbar" />
</android.support.design.widget.AppBarLayout>
<include android:id="@+id/Activity_First_Content_Include"
layout="@layout/activity_first_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@id/Activity_AppBar"/>
</android.support.constraint.ConstraintLayout>
activity_first_content
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFF"
tools:context=".StartScreens.Home.HomeScreens.FirstActivity">
<!-- Content -->
<EditText
android:id="@+id/EditText_Title"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
app:layout_constraintTop_toBottomOf="parent"
android:ems="10" />
<RatingBar
android:id="@+id/Activity_RatingBar_Stars"
android:layout_width="241dp"
android:layout_height="42dp"
app:layout_constraintLeft_toRightOf="@+id/TextView_Stars"
android:inputType="number"
android:maxLength="1"
app:layout_constraintTop_toBottomOf="@+id/EditText_Title"
android:layout_marginStart="20dp" />
<!-- A lot more content -->
<Button
android:id="@+id/Button_Clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="Clear"
android:text="@string/clear"
android:layout_marginTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.775"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toLeftOf="@+id/Button_Submit" />
<Button
android:id="@+id/Button_Submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="ButtonClickSubmit"
android:text="@string/submit"
android:layout_marginTop="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.775"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintLeft_toRightOf="@+id/Button_Clear" />
</android.support.constraint.ConstraintLayout>
</ScrollView>
Wenn ich Fügen Sie diese Zeile app:layout_constraintTop_toBottomOf="parent">
zum AppBarLayout
, ich blättern kann der gesamte Inhalt, auch die Tasten zu sehen. Aber dann ist der enthaltene Inhalt oberhalb der AppBar
/Toolbar
, und die Toolbar
ist weg.
Zusammengefasst, mein Layout ist scrollbar, aber die beiden unteren Tasten sind ausgeschnitten. Die graue Bildlaufleiste am rechten Bildschirmrand bewegt sich beim Scrollen nach unten "unter"/"hinter" dem Bildschirm.
Irgendwelche Ideen, wie ich meinen Code verbessern kann?
Nur eine kurze Frage, in Ihrem activity_first_content Layout, wo Ihr TextView_Stars Element, das Sie in Ihrer Bewertungsleiste erwähnt haben – Nero
Die Layout-Datei ist riesig, so dass ich nur ausgeschnitten viel Inhalt. Ich weiß, dass der Code jetzt nicht viel Sinn macht, aber der Inhalt der Datei war nicht wichtig. Das Layout funktioniert korrekt, nur das Scrollen – Fred
In Ihrer XML-Datei der obersten Ebene verwendet Ihr ''-Tag eine' wrap_content'-Höhe. Funktioniert es, wenn Sie das zu "0dp" ändern und 'app: layout_constraintBottom_toBottomOf =" parent "' hinzufügen? –