0

I want to create a scrollview with items I add programmatically and at the bottom a fixed button. But with the code below I see no button.

The code:

<LinearLayout android:id="@+id/list_warrantys" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:fillViewport="true"> <LinearLayout android:id="@+id/show_warratys" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> </LinearLayout> </ScrollView> <Button android:id="@+id/add_warranty" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@drawable/mybutton" android:text="@string/add_button" android:layout_marginBottom="5dp"/> </LinearLayout> 

Pciture of screen

1 Answer 1

2
<RelativeLayout android:id="@+id/list_warrantys" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <ScrollView android:layout_above="@+id/add_warranty" android:layout_width="match_parent" android:layout_height="match_parent" android:fillViewport="true"> <LinearLayout android:id="@+id/show_warratys" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="wrap_content"> </LinearLayout> </ScrollView> <Button android:id="@+id/add_warranty" android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:background="@drawable/mybutton" android:text="@string/add_button" android:layout_marginBottom="5dp"/> 

Use RelativeLayout as root and set android:layout_alignParentBottom="true" to your button and android:layout_above="@+id/add_warranty" to your ScrollView

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.