Android студия Framelayout - Listview под верхней частью - PullRequest
0 голосов
/ 07 июня 2018

В настоящее время я пытаюсь повторить пользовательский интерфейс, который вы видите на картинке внизу.Я уже создал верхнюю часть, но я начал бороться, затем я добрался до части списка (часть под синим фоновым изображением).Как я могу сделать просмотр списка под верхней частью?

Я уже пытался сделать относительное расположение, но это не дало бы основание остальным после того, как я попытался поместить все в линейное расположение, которое нелибо не работает

The picture

<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


            <RelativeLayout
                android:id="@+id/upper_section"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="#144947">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_centerVertical="true"
                    android:layout_marginEnd="30dp"
                    android:text="25"
                    android:textColor="#ffffff"
                    android:textSize="30dp" />


            </RelativeLayout>

            <RelativeLayout
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginEnd="150dp"
                android:background="#33e4e4e4">

                <TextView
                    android:id="@+id/navn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="20dp"
                    android:text="Name"
                    android:textColor="#ffffff"
                    android:textSize="30dp" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

                <TextView
                    android:id="@+id/text_view_date"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignStart="@+id/navn"
                    android:layout_marginBottom="14dp"
                    android:text="Torsdag den 7. juni 2018"
                    android:textColor="@color/ColorSeconddaryText"
                    android:textSize="12dp" />

            </RelativeLayout>

    </FrameLayout>

    <!-- Container for contents of drawer - use NavigationView to make configuration easier -->
    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:menu="@menu/drawer_view"
        app:headerLayout="@layout/nav_header">

    </android.support.design.widget.NavigationView>

</android.support.v4.widget.DrawerLayout>

1 Ответ

0 голосов
/ 07 июня 2018

РЕДАКТИРОВАТЬ

<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

       <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <RelativeLayout
                android:id="@+id/upper_section"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:background="#144947">

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentEnd="true"
                    android:layout_centerVertical="true"
                    android:layout_marginEnd="30dp"
                    android:text="25"
                    android:textColor="#ffffff"
                    android:textSize="30dp" />
            </RelativeLayout>

            <RelativeLayout
                android:id="@+id/test_id"
                android:layout_width="match_parent"
                android:layout_height="200dp"
                android:layout_marginEnd="150dp"
                android:background="#33e4e4e4">

                <TextView
                    android:id="@+id/navn"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentStart="true"
                    android:layout_centerVertical="true"
                    android:layout_marginStart="20dp"
                    android:text="Name"
                    android:textColor="#ffffff"
                    android:textSize="30dp" />

                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:theme="@style/ThemeOverlay.AppCompat.ActionBar" />

                <TextView
                    android:id="@+id/text_view_date"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignStart="@+id/navn"
                    android:layout_marginBottom="14dp"
                    android:text="Torsdag den 7. juni 2018"
                    android:textSize="12dp" />
            </RelativeLayout>

            <ListView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/test_id"/>
        </RelativeLayout>
    </FrameLayout>

    <!-- Container for contents of drawer - use NavigationView to make configuration easier -->
    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:fitsSystemWindows="true">
    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

ОРИГИНАЛ

Поместите ваши два RelativeLayouts в LinearLayout или другой RelativeLayout.

FrameLayouts не использует позиционирование у своих дочерних элементов (LinearLayouts естественным образом размещается один за другим, RelativeLayouts позволяет более абсолютное позиционирование).Когда у вас есть FrameLayout с двумя дочерними элементами, они могут быть расположены не так, как если бы у одного дочернего элемента был чрезмерный запас.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...