T
T
TimkaTV2015-07-12 14:28:56
Android
TimkaTV, 2015-07-12 14:28:56

How to correctly markup?

Good afternoon,
There is a markup:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
    android:background="@color/space_main">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/scrollView">

        <RelativeLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            ........

            <GridView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/gridView"
                android:layout_alignParentLeft="false"
                android:layout_alignParentStart="true"
                android:layout_below="@+id/photo_lable"
                android:verticalSpacing="5dp"
                android:gravity="center"
                android:numColumns="auto_fit"
                android:columnWidth="110dp"
                android:horizontalSpacing="5dp"
                android:layout_alignParentRight="true"
                android:layout_alignParentEnd="true" />

            .......

        </RelativeLayout>
    </ScrollView>

</RelativeLayout>

The entire page from start to finish should be scrollable. The problem is that I do not know in advance how much space is needed for the GridView. I put android:layout_height="match_parent" and as a result only 1 line is displayed. Everything else is cut off. I can’t exactly set android:layout_height, because I don’t know in advance how many elements there will be.
Thank you!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
TimkaTV, 2015-07-12
@TimkaTV

Thank you!
Decision

E
Emin, 2015-07-12
@Ewintory

In general, it is wrong to use GridView, ListView inside ScrollView. They do not know how to calculate their maximum height. Try to do without ScrollView.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question