1

In my app I use the following FrameLayout as a container for a fragment that will be a footer:

<FrameLayout
android:id="@+id/frameLayoutFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content" 
android:layout_alignParentBottom="true"/>

In my activity I use the following code in order to add the fragment:

FragmentManager fm = getSupportFragmentManager();
FragmentTransaction ft = fm.beginTransaction();
mFooterFragment = new FooterFragment();
ft.add(R.id.frameLayoutFooter, mFooterFragment);
ft.commit();

And the layout of my footer fragment is:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/footerContainer"
android:layout_width="fill_parent"
android:layout_height="165dip"
android:layout_alignParentBottom="true"
android:background="#15355b" >

<RelativeLayout
    android:id="@+id/relativeLayoutTopSetcion"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

..... some buttons and imageviews here...
</RelativeLayout>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/relativeLayoutBottomSetcion"
    android:layout_width="fill_parent"
    android:layout_height="350dip"
    android:layout_alignParentBottom="true"
    android:visibility="**invisible**" >
..... some more imageviews and textviews here...
</RelativeLayout>
</RelativeLayout>

At some point I would like to expand the footer and put some more imageviews and textviews in it, but unfortunately all my tries have failed, the result is that the fragment's FrameLayout does get expanded but its children stays in the upper (old bottom) part even although they have alignParentBottom set to true - what i get is that the footer's height does change and its bottom newly added part is transparent, which makes me think that the its children are not updated with its new layout params. Another thing is that I do see the the change of the mRelativeLayoutBottomSetcion.setVisibility(View.VISIBLE) -but is not in the bottom (the newly expanded section) of the FrameLayout but in the bottom of the original size before expanding.

in order to expand the fragment I used the following code from the activity this framents belongs to:

ViewGroup.LayoutParams params = mFrameLayoutFooter.getLayoutParams();
params.height = 500; 
mFrameLayoutFooter.requestLayout();
// setting the bootom relative layout to be visible
mRelativeLayoutBottomSetcion.setVisibility(View.VISIBLE);

What am I doing wrong ?

Is there a known UI pattern for expendable footer ?

Thanks in advance

amitos80
  • 183
  • 1
  • 18
  • did you try `frameLayout.invalidate();` ? – Mohammad Ersan Jul 11 '12 at 14:33
  • Yes, didnt work... I also tried to take RelativeLayout's content into a new fragment (instead of setting it to visible) and adding it to the footer in runtime (on a button's click) - but that also gives me the exact same result..., any ideas on how to implement expandable footer ?? – amitos80 Jul 12 '12 at 14:52
  • you can try to insert in the fragment layout viewstub with the attributes alignParentBottom and inflate the viewstub. It should work – rallat Jul 13 '12 at 14:02

3 Answers3

0

I noticed a few things in your code that might be the problem:

  1. The parent RelativeLayout in the fragment (with @+id/footerContainer) has a fixed android:layout_height of 165dip, change this to match_parent instead.

  2. You can also remove the android:layout_alignParentBottom="true" on it too (it won't work anyway since its parent is a FrameLayout - layout_alignParentBottom only works on children of RelativeLayout).

  3. Since we change the 165dip to match_parent on point #1, you should change the android:layout_height="wrap_content" on the FrameLayout (with @+id/frameLayoutFooter) to 165dip to get what you want.

Joe
  • 14,039
  • 2
  • 39
  • 49
0

There are some things I didn't get it, and this could answer your question:

Firstly, why do you have a RelativeLayout (relativeLayoutBottomSetcion) with 350dip inside another relative layout that has only 165dip?

I think you should try to set the FrameLayout height to 165dip, and your RelativeLayout (footerContainer) height to fill_parent. This will allow your "footerContainer" to have the same height as your FrameLayout, even after you change its height to 500dip. (That's when you'll make relativeLayoutBottomSetcion VISIBLE, just like you're already doing)

Also, you should set the visibility to GONE instead INVISIBLE, because INVISIBLE makes you RelativeLayout occupy space on the screen, but without painting its content.

To have it finished, remove android:layout_alignParentBottom="true", because you don't need it, since the RelativeLayout parent is a FrameLayout, and this attribute only works if the parent is a RelativeLayout.

Leaudro
  • 1,021
  • 8
  • 7
0

Eventually, I used a RelativeLayout with visibility set to gone, and expand it using resize animation taken from here. cheers!

Community
  • 1
  • 1
amitos80
  • 183
  • 1
  • 18