2016-01-22 42 views
1

我正在使用listview與nestedscrollview和coordinatelayout,但是當我在設計佈局的預覽中看到它顯示listview的第一項,並且當我運行應用程序時它顯示第一項,是我的XML任何一個可以告訴有什麼問題使用座標佈局列表視圖只顯示預覽中的第一項

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     android:fitsSystemWindows="true"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbarsubcat" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:layout_collapseMode="pin" 
      /> 



    </android.support.design.widget.AppBarLayout> 

    <android.support.v4.widget.NestedScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"> 


      <ListView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:id="@+id/lvsubcategory" 
       android:divider="#ffffff" 
       android:dividerHeight="10dp" 

       /> 


    </android.support.v4.widget.NestedScrollView> 



</android.support.design.widget.CoordinatorLayout> 
+0

刪除嵌套的滾動視圖。 –

+0

no change..sti同樣的結果 – albert

+0

刷新視圖在更改後預覽(預覽屏幕上的第三個按鈕) –

回答

2
<?xml version="1.0" encoding="utf-8"?> 

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:fitsSystemWindows="true" 
     android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbarsubcat" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      app:layout_collapseMode="pin" 
      app:layout_scrollFlags="scroll|enterAlways" /> 


    </android.support.design.widget.AppBarLayout> 


    <ListView 
     android:id="@+id/lvsubcategory" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:divider="#ffffff" 
     android:dividerHeight="10dp" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 


</android.support.design.widget.CoordinatorLayout> 
+0

我已刪除嵌套滾動並將此行添加到列表視圖中: app:layout_behavior =「@ string/appbar_scrolling_view_behavior」在預覽中查看。 –

+0

listview正在顯示,但我的工具欄是穩定的...那麼我怎麼能隱藏? – albert

+0

onscroll我的工具欄現在不隱藏 – albert