2015-01-26 110 views
0

在佈局的頂部有一個textview,button和imageview..etc的元素,但大部分有listview。這是必需的,當我們滾動時,頂層元素必須用listview滾動。在滾動視圖相對的相對佈局和列表視圖android

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res/com.revolage.vkcommunity" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@color/vk_white" 
android:orientation="vertical" 
tools:context="com.egay.borsh.fragments.MainActivity" > 

<RelativeLayout 
    style="@style/ActionBarStyle" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="@dimen/activity_vertical_margin" > 

    <RelativeLayout 
     android:id="@+id/action_bar_relative_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingBottom="@dimen/activity_vertical_margin" > 

     ...... 
    </RelativeLayout> 

    <com.costum.android.widget.PullAndLoadListView 
     android:id="@+id/main_post_list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/header_linear_layout" /> 
</RelativeLayout> 

但如此,沒有什麼是滾動。

+0

由於ListView已經包含了一個滾動機制,所以你不應該在'ScrollView'中放置'ListView'。 – 2015-01-26 18:56:58

回答

0

對於這種情況,您需要使用可展開的ListView。它的列表視圖總是擴展。所以你可以把它放在ScrollView中。對於你的pullAndReflesh自定義列表視圖,你應該檢查一個可擴展的並從中擴展你的類。你可以在google上找到這門課。

爲什麼一個listView裏面的scrollview?

因爲有時候你需要使用一個不能與LinearLayout一起使用的適配器。

相關問題