2017-04-18 169 views
0

我有一個圖像滑塊頂部和下面的列表視圖。列表視圖滾動,但滑塊仍然是靜態的,我想要的是,如果我滾動,滑塊也應該上去。請提供解決方案this is my layoutAndroid滾動整個屏幕不僅列表視圖

這是我的XML代碼

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:custom="http://schemas.android.com/apk/res-auto" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.dzone.image_ki_duniya.MainActivity"> 

<com.daimajia.slider.library.SliderLayout 
    android:id="@+id/cover" 
    android:layout_width="match_parent" 
    custom:pager_animation="Accordion" 
    custom:auto_cycle="true" 
    custom:indicator_visibility="visible" 
    custom:pager_animation_span="1100" 
    android:layout_height="200dp"/> 

<com.daimajia.slider.library.Indicators.PagerIndicator 
    android:id="@+id/custom_indicator" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    custom:selected_color="#0095BF" 
    custom:unselected_color="#55333333" 
    custom:selected_drawable="@drawable/left" 
    custom:shape="oval" 
    custom:selected_padding_left="6dp" 
    custom:selected_padding_right="6dp" 
    custom:unselected_padding_left="2dp" 
    custom:unselected_padding_right="2dp" 
    android:layout_centerHorizontal="true" 
    android:layout_alignParentBottom="true" 
    custom:selected_width="6dp" 
    custom:selected_height="6dp" 
    custom:unselected_width="6dp" 
    custom:unselected_height="6dp" 
    android:layout_marginBottom="20dp" 
    /> 
<!--<com.daimajia.slider.library.Indicators.PagerIndicator--> 
    <!--android:id="@+id/custom_indicator2"--> 
    <!--style="@style/AndroidImageSlider_Corner_Oval_Orange"--> 
    <!--android:layout_centerHorizontal="true"--> 
    <!--android:layout_alignParentBottom="true"--> 
    <!--android:layout_marginBottom="20dp"--> 
    <!--/>--> 


<ListView 
    android:id="@+id/listview" 
    android:layout_marginTop="5dp" 
    android:layout_below="@+id/cover" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"></ListView> 

+1

解決方法之一就是將想要滾動的部分作爲標題視圖放入列表視圖中。請參閱https://developer.android.com/reference/android/widget/ListView.html#addHeaderView(android.view.View) – njzk2

+0

@ njzk2的解決方案是實現您想要的目標的唯一方法。 –

回答

0

在滾動視圖將所有的東西。確保scrollview只能託管一個父視圖。