I have a table layout in which i have declared a button statically in the XML file. I add rows dynamically in the program. I want the button to be set at the very end of the table layout.
I tried doing that using android:layout_gravity=”bottom” but that is not helping.
Any solutions ?
This is my XML
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:scrollbars="horizontal|vertical"
android:scrollbarStyle="outsideInset" >
<TableLayout
android:id="@+id/table"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/back"
android:layout_gravity="bottom"
/>
</TableLayout>
</ScrollView>
I don’t know exactly it will work for you but what you can do is to remove your button by using remove and then add it at run time after adding all your elements.
Example:
May be you need layout param of your button so you can get it easily.
remove your button from layout.
ADD ALL YOUR VIEW AT RUNTIME.
Add your button again.
I havnt tried this code but I think it should work. In some of the cases you don’t need layout params so you can ignore it too.