A
A
Alex Rubera2016-11-11 17:19:24
Android
Alex Rubera, 2016-11-11 17:19:24

How to display a list and an additional text block on the screen?

Good afternoon!
The application has a screen with order details: a text description (delivery address, etc.) + a list of goods. Something like this:
d23221cc7fb54417a62320f4ef9deed4.png
How to properly layout such a layout?

<LinearLayout>

    <LinearLayout>
        <TextView />
        <TextView />
        <TextView />
    </LinearLayout>
    
    <android.support.v7.widget.RecyclerView />

</LinearLayout>

If I do this, then the list of products takes up only the rest of the screen and scrolls within this small area. I would like the whole thing to scroll. Is that possible? Maybe you need not RecyclerView, but something else?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
Alex Rubera, 2016-11-14
@alx

In the end, I came up with the following solution:

<ScrollView>

    <LinearLayout>

        <LinearLayout
            android:id="@+id/order_items_list" />

        <LinearLayout
            android:id="@+id/order_extra_details">
            
            <TextView />
            <TextView />
            <TextView />
            ...
            
        </LinearLayout>

    </LinearLayout>

</ScrollView>

In turn, I fill the order_items_list programmatically in Activity:onCreate using inflater.inflate.

N
Ne-Lexa, 2016-11-11
@NeLexa

I think you need to wrap it all in a ScrollView.

M
MikkiMouse, 2016-11-11
@MikkiMouse

As an option, use different ViewHolders for your RecyclerView. The first element will be a holder with a product description, the rest will be a holder for list items.

B
bot8, 2016-11-11
@bot8

I think you should use a parallax effect to make your LinearLayout with TextView go off screen on scroll. Read how to do it here or there .
simple_coordinator.gif

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question