2011-10-13 34 views
3

我有了这个RelativeLayout我使用:使用包含ExpandableListView上RelativeLayout的滚动型

<?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> 

问题是我想给它一个ScrollView或similiar内部使用 - 整个布局不适合在屏幕上,尤其是当您将几个组添加到ExpandableListView时。

我试过把RelativeLayout放在ScrollView里面,但它根本没有工作。

如何在其中设置RelativeLayout的滚动屏幕?

回答

4

将所有视图放在可扩展列表视图上作为listView标题,以及下面所有视图作为listView脚注。然后你就可以滚动了。

+0

你是什么意思的listview页眉和页脚? – KaiserJohaan

0

这是一个棘手的问题。在这里有几个关于如何在ListView中使用ScrollView的讨论。看看这个问题:Scrolling with Multiple ListViews for Android。这个想法是只有一个列表(创建一个自定义适配器)并在Expandable列表前后添加页眉和页脚。

0

除了页眉/页脚的方法,如果你将定义所有的视图之前expandableList并给它的相对位置(layout_above/layout_below),你会得到所需的视图。