2

我有一個佈局片段的問題:如何在舊的API <21中替換NestedScrollView?

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_gravity="fill_vertical" 
    android:clipToPadding="false" 
    android:fillViewport="true" 
    android:nestedScrollingEnabled="true" <!-- this don't work with api levels older than 21 --> 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     tools:context=".MainActivity"> 

    <ListView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:clipToPadding="false" 
     android:id="@+id/elements" /> 
    </LinearLayout> 

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

我需要消失/出現工具欄,當用戶滾動片段。 此方法不適用於API 19(例如):您將如何處理此Android設備?

回答