1

I would like my listview to not scroll, but go beyond the viewport making the whole screen scrollable. Is this possible? As you can see the listview below gets cut off from the bottom of the viewport adding a scrollbar to it.

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/detail_view"
    style="@style/DetailView" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginBottom="20dip"
            android:adjustViewBounds="true"
            android:maxHeight="100dip"
            android:maxWidth="100dip"
            android:orientation="horizontal" >

            <ImageView
                android:id="@+id/player_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:adjustViewBounds="true"
                android:background="@drawable/border"
                android:maxHeight="100dip"
                android:maxWidth="100dip" >
            </ImageView>
        </LinearLayout>

        <TextView
            android:id="@+id/textview_player_number"
            style="@style/TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:textSize="24sp"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/textview_player_name"
            style="@style/TextView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center" >
        </TextView>

        <ListView
            android:id="@+id/meta_list"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:scrollbars="none"
            android:background="#FFFFFF"
            android:cacheColorHint="#00000000">
        </ListView>
    </LinearLayout>

</RelativeLayout>


<style name="DetailView">
    <item name="android:layout_width">wrap_content</item>
    <item name="android:layout_height">match_parent</item>
    <item name="android:orientation">vertical</item>
    <item name="android:paddingTop">20dp</item>
    <item name="android:paddingBottom">20dp</item>
    <item name="android:paddingLeft">20dp</item>
    <item name="android:paddingRight">20dp</item>
</style>
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341
  • Sounds like you want a LinearLayout instead of a list view. Then you can wrap the entire view in a ScrollView – cyroxis Feb 11 '15 at 18:24
  • I guess I could do that, no way to make the height not scrollable for a listview? I assume wrapping the entire view in a scrollview will make the whole screen scrollable? – Mike Flynn Feb 11 '15 at 18:28
  • You should't put a ListView inside a ScrollView: http://stackoverflow.com/questions/6210895/listview-inside-scrollview-is-not-scrolling-on-android . – Ziem Feb 11 '15 at 18:37
  • @MikeFlynn The whole point of the ListView is to scroll and only load the needed content. One other option would be to use setHeaderView() as pointed out in an answer below. If it is always going to be a relatively small set of data do whichever is simpler to implement. If it will be a potentially large set of data use setHeaderView() – cyroxis Feb 11 '15 at 19:20

1 Answers1

0

If you want to make the whole page scrollable you need to use header: ListView#addHeaderView. Player information (avatar/name/etc) will be your header. Just extract them to another layout and use addHeaderView method on your ListView.

Ziem
  • 6,579
  • 8
  • 53
  • 86