I have the following layout: I need to keep the button at the bottom of screen and it should be visible to the user. The rest of the layout should scroll.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context="com.vfc.sargroup.SalesOrderActivity$PlaceholderFragment" > <ScrollView android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@+id/bottomLinearLayout" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Select Distributor Name" android:textAppearance="?android:attr/textAppearanceMedium" /> <Spinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="wrap_content" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Payment Collection" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Product Category" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> <TableLayout android:id="@+id/salesTableLayout" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginRight="20dp" android:stretchColumns="*" > </TableLayout> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Total QTY" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Total Price" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > <requestFocus /> </EditText> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Remark" android:textAppearance="?android:attr/textAppearanceMedium" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" > </EditText> </LinearLayout> </ScrollView> <LinearLayout android:id="@+id/bottomLinearLayout" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_below="@+id/scrollView1" android:layout_centerHorizontal="true" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Submit" /> </LinearLayout> </RelativeLayout>
I just need to do scroll my view and keep the button appeared on the screen at the bottom.
The problem is with
android:layout_above="@+id/bottomLinearLayout"
I get the error
Circular dependencies cannot exist in RelativeLayout
What is wrong with my layout?
The problem is caused because there is a circular reference in the layout parameters.
For example, when view B is layout_below view A, view A can't reference view B anymore in it's below, alignRight etc. This can also exist between multiple views: A references B references C. In that scenario C can't reference A because of a circular dependency.
You Used :-
bottomLinearLayout is below scrollView1 And then you said that scrollView1 is above bottomLinearLayout
It dosen't work like that. Use one
You cannot say the bottomLinearLayout is below scrollView1 then say scrollView1 is above bottomLinearLayout. Only do one, not both.
This is circular because it will try to position itself after it figures out where the other one is at... Which is waiting on the first one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With