gregaj
gregaj

Reputation: 338

Elements below the expandable list - not floating footer

Is there any option to put elements below the expandable list, let me explain: I already implemented elements below the list, but they are behaving like footer - floating at the bottom of the screen.

But if i place elements below the list in xml, elements become hidden when any group is expanded.

at the moment my layout is behaving like this

http://shrani.si/f/2s/ba/ga2VKfi/lay2.jpg

but i want to be like this at the end of the list

http://shrani.si/f/42/4m/2GAcNu6T/lay3.jpg

My layout at the moment

<LinearLayout
                android:id="@+id/linearLayoutListExer"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dip"
                android:background="#ffffff"
                android:gravity="center_vertical"
                android:orientation="vertical">

                <ExpandableListView
                    android:id="@+id/ExerciseELV"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@+id/linearLayoutStatus"
                    android:layout_weight="1"
                    android:groupIndicator="@null" />

                <LinearLayout
                    android:id="@+id/relativeFooter"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/linearLayoutListExer"

                    android:background="#ffffff"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/textViewBellowExercise"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:padding="10dip"
                        android:text="The following exercises will help you lose body weight"
                        android:textAppearance="?android:attr/textAppearanceSmall"

                        />

                    <LinearLayout
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_below="@id/textViewBellowExercise">


                        <Button
                            android:id="@+id/buttonFaceit"
                            android:layout_width="0dp"
                            android:layout_height="20dp"
                            android:layout_margin="5dp"
                            android:layout_weight="1"
                            android:background="@color/green"
                            android:text="FaceIT!"
                            android:textColor="@color/white" />

                        <Button
                            android:id="@+id/buttonChallenge"
                            android:layout_width="0dp"
                            android:layout_height="20dp"
                            android:layout_margin="5dp"
                            android:layout_weight="1"
                            android:background="@color/red"
                            android:text="Challenge"
                            android:textColor="@color/white" />
                    </LinearLayout>
                </LinearLayout>
            </LinearLayout>

Upvotes: 0

Views: 295

Answers (2)

gregaj
gregaj

Reputation: 338

I'm new to android so i'm sorry for any "stupid" questions i may be asking.

I ended up using addfooterview method which works great.

You need to separate footer layout in its own xml and then inflate it and add it to expandable listview.

    View footer=inflater.inflate(R.layout.activity_main_footer,null);
    elv.addFooterView(footer); 

Upvotes: 0

Vansi
Vansi

Reputation: 787

Your following property should change. Instead of android:layout_below="@id/linearLayoutListExer"

you should write android:layout_below="@id/ExerciseELV"

for the LinearLayout with android:id="@+id/relativeFooter"

This will make the bottom layout appear below the listview

Upvotes: 1

Related Questions