Android: Adding Components To RelativeLayout
in My screen, i want to have Hearder(specifically image) on top, and List, and at bottom i want to have small imagebuttons (like youtube,facebook). I'm using RelativeLayout.. firs
Solution 1:
In a RelativeLayout
it matters in which order you add the child views (since the latter can be bound to the ones added previously).
I think this is the problem in your layout, you have a fill_parent
/match_parent
high view already inside (the ListView
), and there is no room for the footer.
You should change the order of your views inside the RelativeLayout
:
- first you should add the header view
(and bind it to the top:
android:align_parent_top="true"
), then - the footer with buttons (and bind it
to the bottom:
android:align_parent_bottom="true"
), and - the
ListView
which should fill up the empty space will go in as the thirds view, withandroid:layout_below="header_view"
andadroid:layout_above
="footer_view"`
Your layout would then look like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout>
<image android:id="@+id/header"
android:layout_alignParentTop="true"></image>
<RelativeLayout android:id="@+id/footer"
android:layout_alignParentBottom="true">
<ImageButton></ImageButton>
</RelativeLayout>
<ListView
android:layout_below="@id/header"
android:layout_above="@id/footer"></ListView>
</RelativeLayout>
Post a Comment for "Android: Adding Components To RelativeLayout"