Scrollview floating linearlayout function will not scroll

Here is my gui xml:

<FrameLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/frameLayout" xmlns:android="http://schemas.android.com/apk/res/android"> <ScrollView android:layout_width="fill_parent" android:id="@+id/scrollView" android:fillViewport="true" android:layout_height="fill_parent"> <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:id="@+id/contentLayout" android:padding="5dip" android:fadingEdge="vertical" android:layout_height="fill_parent"> <TextView android:id="@+id/lblName" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_name"></TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/nameLayout"> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/chkName"></CheckBox> <TextView android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:id="@+id/txtName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="@color/white" android:text="TextView" android:layout_weight="1" android:textSize="20dip"></TextView> </LinearLayout> <TextView android:id="@+id/lblPhone" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_phone"></TextView> <LinearLayout android:isScrollContainer="false" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstPhone"></LinearLayout> <TextView android:id="@+id/lblEmail" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_email"></TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstEmail"></LinearLayout> <TextView android:id="@+id/lblAddress" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/label_address"></TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstAddress"></LinearLayout> </LinearLayout> </ScrollView> <LinearLayout android:background="@color/grey" android:layout_width="fill_parent" android:paddingTop="5dip" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_gravity="bottom|right" android:id="@+id/commandLayout"> <Button android:id="@+id/btnToClipBoard" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="To ClipBoard" android:layout_weight="1"></Button> <Button android:id="@+id/btnCancel" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Cancel" android:layout_weight="1"></Button> </LinearLayout> </FrameLayout> 

LinearLayout id: commandLayout is perfectly located at the bottom of the window. But LinearLayout id: contentLayout will not scroll. If I move commandLayout inside scrollView, all scrolls. This is not what I want, though. I want to see buttons, no matter how long the contentLayout takes. Any help would be greatly appreciated. I spent most of the day on this ... Thanks.

Edit: Thanks for all the answers. Going from FrameLayout to RelativeLayout and setting the parentLayout to align with the parent bottom, and the top of the scrollview parent is the best solution.

+4
source share
3 answers

I changed the basic layout, namely "frameLayout" to a relative layout.

I do this so that "commandLayout" is below "scrollView". It doesn't make sense if the things you are about to show are hidden behind "commandLayout"

I added alignParentBottom to "commandLayout". I also added layout_above = "@ + id / commandLayout" on top of "scrollView"

this is working xml and yes, this is scroll =)

 <RelativeLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/relativeLayout" xmlns:android="http://schemas.android.com/apk/res/android" > <ScrollView android:layout_width="fill_parent" android:id="@+id/scrollView" android:fillViewport="true" android:layout_height="fill_parent" android:layout_above="@+id/commandLayout" > <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:id="@+id/contentLayout" android:padding="5dip" android:fadingEdge="vertical" android:layout_height="fill_parent" > <TextView android:id="@+id/lblName" android:layout_width="fill_parent" android:layout_height="wrap_content" > </TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:id="@+id/nameLayout" > <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/chkName"> </CheckBox> <TextView android:layout_marginLeft="4dip" android:layout_marginRight="4dip" android:id="@+id/txtName" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textColor="#FFFFFF" android:text="TextView" android:layout_weight="1" android:textSize="20dip"> </TextView> </LinearLayout> <TextView android:id="@+id/lblPhone" android:layout_width="fill_parent" android:layout_height="wrap_content" > </TextView> <LinearLayout android:isScrollContainer="false" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstPhone"> </LinearLayout> <TextView android:id="@+id/lblEmail" android:layout_width="fill_parent" android:layout_height="wrap_content" > </TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstEmail" > </LinearLayout> <TextView android:id="@+id/lblAddress" android:layout_width="fill_parent" android:layout_height="wrap_content" > </TextView> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:id="@+id/lstAddress"> </LinearLayout> <TextView android:id="@+id/LongText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="40sp" android:text="This is a super long text that will hopefully cover the whole screen so as the scroll will work." > </TextView> <TextView android:id="@+id/AnotherLongText" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textSize="40sp" android:text="This is another super long text to show that the scrolling will work even more!" > </TextView> </LinearLayout> </ScrollView> <LinearLayout android:background="#737754" android:layout_width="fill_parent" android:paddingTop="5dip" android:layout_height="wrap_content" android:orientation="horizontal" android:id="@+id/commandLayout" android:layout_alignParentBottom="true" > <Button android:id="@+id/btnToClipBoard" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="To ClipBoard" android:layout_weight="1"> </Button> <Button android:id="@+id/btnCancel" android:layout_width="fill_parent" android:layout_height="fill_parent" android:text="Cancel" android:layout_weight="1"> </Button> </LinearLayout> </RelativeLayout> 
+1
source

Do I need to use FrameLayout? If I understood your purpose correctly, RelativeLayout did what you expect;

 <RelativeLayout ...> <LinearLayout android:layout_alignParentBottom="true" android:id="@+id/commandLayout" ... /> <ScrollView android:layout_alignParentTop="true" android:layout_above="@id/commandLayout" android:id="@+id/scrollView" .../> </RelativeLayout> 
+1
source

I probably did not understand that the problem is complete, but here it goes ... I tried the layout file that you put and found that the bottom of the list is hidden behind two buttons. So I added the following to the ScrollView widget, and it seemed beautiful.

 android:layout_marginBottom="60dip" 

But maybe I'm missing something.

0
source

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


All Articles