HorizontalScrollView oberhalb ConstraintLayout positionieren

H

haner

Ambitioniertes Mitglied
0
Was muss ich an meinem Code verändern, damit der HorizontalScollView (enthält Button 1) oberhalb von dem ConstraintLayout mit den zwei anderen Buttons positioniert ist? Aktuell beginnen beide Layouts om oberen Bildrand, sodass sich die Buttons überlagern.

Code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.ta.mar.test.MainActivity">

    <HorizontalScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <android.support.constraint.ConstraintLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">

            <Button
                android:id="@+id/btnimscroll"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:text="Button 1"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.0"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

        </android.support.constraint.ConstraintLayout>
    </HorizontalScrollView>

    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <Button
            android:id="@+id/btnzumlogin"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="8dp"
            android:layout_marginStart="8dp"
            android:layout_marginTop="8dp"
            android:text="Button 2"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <Button
            android:id="@+id/btnhinzu"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="8dp"
            android:layout_marginRight="8dp"
            android:layout_marginTop="8dp"
            app:layout_constraintStart_toEndOf="@+id/btnzumlogin"
            android:text="Button 3"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </android.support.constraint.ConstraintLayout>

</android.support.v4.widget.DrawerLayout>
 
Die beiden Layouts in ein LinearLayout mit orientation:vertical packen.
Es kann sein, dass du im ConstraintLayout dann nicht mehr height:match_parent machen kannst. Dann solltest du dir layout_weight anschauen, damit die View den restlichen zur Verfügung stehenden Platz beansprucht.
 
  • Danke
Reaktionen: swa00
Danke für die Hilfe. Hat so funktioniert. Height:match_parent kann man trotzdem noch verwenden.
 

Ähnliche Themen

L
Antworten
4
Aufrufe
1.328
lonnie9020
L
A
Antworten
1
Aufrufe
875
koje71
koje71
W
Antworten
0
Aufrufe
725
whazza
W
Zurück
Oben Unten