Question

I have relative layout ("relative") with clickable layout ("clickable") on top, expandable list view ("lview") under "clickable", and "footer" text view with version of my app on bottom of "relative":

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/menu_background" >

<com.reconti.app.widgets.Logo
    android:id="@+id/reconti_menu_tv_logo"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/actionBarSize"
    android:layout_alignParentTop="true"
    android:gravity="center_vertical"
    android:paddingLeft="@dimen/standart_side_margin"
    android:textSize="30sp" />

<RelativeLayout
    android:id="@+id/clickable"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/menu_tv_logo"
    android:layout_marginBottom="10dp"
    android:layout_marginTop="10dp"
    android:clickable="true"
    android:paddingLeft="@dimen/standart_side_margin" >

    <com.reconti.app.widgets.RoundedImageView
        android:id="@+id/menu_profile_avatar"
        android:layout_width="60dp"
        android:layout_height="60dp"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:scaleType="fitCenter"
        android:src="@drawable/com_facebook_profile_picture_blank_portrait" />

    <TextView
        android:id="@+id/menu_user_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_marginLeft="10dp"
        android:layout_toRightOf="@id/menu_profile_avatar"
        android:singleLine="true"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="@color/white" />
</RelativeLayout>

<ExpandableListView
    android:id="@+id/lview"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:childDivider="@color/menu_divider_color"
    android:divider="@color/menu_divider_color"
    android:dividerHeight="1dp"
    android:footerDividersEnabled="false"
    android:groupIndicator="@null"
    android:headerDividersEnabled="false"
    android:listSelector="@drawable/expandable_row_background" />

<TextView
    android:id="@+id/footer"
    android:layout_width="wrap_content"
    android:layout_height="0dp"
    android:layout_alignParentBottom="true"
    android:layout_marginTop="10dp"
    android:gravity="center"
    android:singleLine="true"
    android:textAppearance="?android:attr/textAppearanceSmall"
    android:textColor="@color/white" />
</RelativeLayout>

Everything looks good as long as user hit some option in expandable list. Then "lview" overlaps "footer". I would like to achive effect, that "lview" remains on top of "footer" and "footer" remains on bottom of "relative" and only bottom of "lview" is visible to user (so top goes under "clickable"). I hope I explained it clearly:)

Was it helpful?

Solution

Usually I like to work with linearlayout when needs to keep views above views. I don't like how relative layout works sometimes. Well, you can try my idea, I know this works with list, but didnt try with expandable list (but guess will work).

  • LinearLayout vertical @relative
    • Logo @reconti_menu_tv_logo
    • RelativeLayout @clickable
    • ListView weight 1 @lview
    • TextView @footer

In this, only your ListView will scroll. I don't know if is this what you want. Your logo, clickable and footer will be fixed. The weight 1 is to keep your listivew using all not used space, so your footer will be always on "footer". Don't forget about height 0dp when using weight.

Now, if you want all scrolling, you have to use addHeader(View) and addFooter(View) on your list before set the adapter. (this is the better way)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top