How to place new items in the scroll list

I have a vertical scrollable layout with lots of elements that works great.
I am trying to put a new linearlayout at the bottom of the screen that would NOT be part of a scrollable layout.
That is, it will sit on the buttom (e.g. adview) regardless of the scrollable part. I could only put it in scrollView.
How can I place it below so that it is always visible?

+4
source share
4 answers

Use a RelativeLayout and organize it like this:

<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_alignParentTop="true" android:layout_above="@+id/linearLayoutThatDoesNotScroll" > <LinearLayout android:id="@+id/linearLayoutWithLotofContent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > </LinearLayout> </ScrollView> <LinearLayout android:id="@+id/linearLayoutThatDoesNotScroll" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" > </LinearLayout> </RelativeLayout> 

The focus is on the ScrollView, while at the same time it is aligned with the top of the screen AND above the bottom fixed LinearLayout. It just works.

+19
source

something like that:)

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <ScrollView android:id="@+id/scroll_view" android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="1" > <LinearLayout android:id="@+id/content" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </ScrollView> <LinearLayout android:id="@+id/bottom" android:layout_width="fill_parent" android:layout_height="10dip" /> </LinearLayout> 

You will add the bottom content to the bottom linear line with android: id = bottom :)

+5
source

If you used the vertical LinearLayout to hold the scroll layout, you can add an ad window to the LinearLayout under the scroll layout and it will appear at the bottom of the screen. (if your weights are set correctly and the scroll layout is set to WRAP_CONTENT )

A RelativeLayout will also allow you to adjust the alignment of the ad with the bottom of the scrollable layout, but you still need to make sure that the scrollable layout has been set to WRAP_CONTENT , so it doesn’t automatically take the whole screen.

+1
source
 <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <Button android:id="@+id/dialogButtonOK" android:layout_width="100px" android:layout_height="wrap_content" android:text=" Ok " android:layout_alignParentBottom="true" android:layout_centerInParent="true" android:background="@drawable/button_style" /> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="5dp" android:id="@+id/scrView" android:layout_above="@id/dialogButtonOK" android:layout_alignParentTop="true" > <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content" > <TableLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:stretchColumns="*" android:id="@+id/main_table" > </TableLayout> </HorizontalScrollView> </ScrollView> </RelativeLayout> 

It worked for me

+1
source

Source: https://habr.com/ru/post/1383886/


All Articles