Using a ScrollView on RelativeLayout that contains an ExpandableListView
I've got this RelativeLayout
I am using:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:id="@+id/screen_team_enableproximity"
android:text="Enable proximity"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/screen_team_checkboxproximity"
android:layout_alignBottom="@+id/screen_team_checkboxproximity"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="@+id/screen_team_checkboxproximity"></Button>
<CheckBox
android:layout_width="wrap_content"
android:id="@+id/screen_team_checkboxproximity"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:clickable="false"></CheckBox>
<ExpandableListView
android:layout_width="match_parent"
开发者_高级运维 android:id="@+id/screen_team_teamslist"
android:layout_height="match_parent"
android:layout_below="@+id/screen_team_availableteams"
android:layout_centerHorizontal="true"></ExpandableListView>
<TextView
android:layout_width="wrap_content"
android:id="@+id/screen_team_availableteams"
android:text="Available Teams"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_below="@+id/screen_team_getallteams"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"></TextView>
<Button
android:text="Create Team"
android:id="@+id/screen_team_createteam"
android:layout_height="wrap_content"
android:layout_below="@+id/screen_team_enableproximity"
android:layout_width="match_parent"
android:layout_marginTop="65dip"></Button>
<Button
android:text="Delete Team"
android:id="@+id/screen_team_deleteteam"
android:layout_height="wrap_content"
android:layout_below="@+id/screen_team_createteam"
android:layout_centerHorizontal="true"
android:layout_width="match_parent"></Button>
<Button
android:layout_width="match_parent"
android:text="Get available teams"
android:id="@+id/screen_team_getallteams"
android:layout_height="wrap_content"
android:layout_below="@+id/screen_team_deleteteam"
android:layout_alignParentLeft="true"></Button>
</RelativeLayout>
The problem is I want to it to be used inside a ScrollView
or similiar - the entire layout does not fit on the screen, especially when you add several groups to the ExpandableListView
.
I've tried putting the RelativeLayout
inside a ScrollView
, but it dosn't work at all.
How do I setup a scrolling screen with my RelativeLayout
in it?
Put all the views above the expandable listView as listView header , and all the views below as listView footer. Then you have scrolling enabled for everything.
This is a tricky one. There were several discussion here on SO on how to use ScrollView with ListView. Have a look at this question: Scrolling with Multiple ListViews for Android. The idea is to have only one list (create a custom adapter) and add headers and footers before and after your Expandable list.
Apart from header/footer approach if you will define all the view before expandableList and give it relative position (layout_above/layout_below) , u will get the desired view .
精彩评论