N
N
Nikolay Alekseev2019-10-17 16:25:32
Java
Nikolay Alekseev, 2019-10-17 16:25:32

How to place LIstView along with other elements so that everything fits?

The question is asked as crookedly as possible, but the toaster wants there to be a question mark ...
The bottom line is, there is an activity, where there are only two elements, the code is this:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:descendantFocusability="beforeDescendants"
    android:focusableInTouchMode="true"
    tools:context=".WorkOrdersList">
    <android.support.v7.widget.Toolbar
        android:id="@+id/toolbar_actionbar"
        android:layout_width="match_parent"
        android:layout_height="?android:actionBarSize"
        android:background="?attr/colorAccent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        android:theme="@style/AppTheme.AppBarOverlay"
        app:layout_constraintTop_toTopOf="parent" />
    <ListView
        android:id="@+id/WorkOrdersList"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar_actionbar"
        app:layout_constraintVertical_bias="0.0" />
</android.support.constraint.ConstraintLayout>

The problem is that if there are a lot of elements, then the extreme one does not fit in height and remains beyond the edge of the screen.
I would be grateful for a hint on how to deal with this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
terminator-light, 2019-10-17
@terminator-light

in ConstraintLayout instead match_parentshould be used 0dp- this means that all the allowed space given by the constraints will be used

A
AndroidRS, 2019-10-18
@AndroidRS

Learn to ask questions correctly, and so I will try to answer you at random. For item on the root element, replace match_parent with wrap_content.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question