5

Ich habe eine NestedScrollView (Teil der Standard-Scrolling-Aktivität), die ein CoordinatorLayout und RecyclerView enthält, um Karten mit einigen Informationen anzuzeigen. Das Layout ist so ausgelegt, dass die Karten außerhalb des Bildschirms angezeigt werden können, wenn zu viele vorhanden sind und der Benutzer zu ihnen herunterscrollen kann. Aus irgendeinem Grund hat die Schriftrolle jedoch keinen Schwung dazu. Ich sah mir um und eine vorherige Frage gesagt, wie das intertial blättert in einem Scrollview (Android ScrollView disable Inertial scrolling) zu deaktivieren, so dass ich versuchte, das Gegenteil zu tun:Interstitial Scroll in NestedScrollView (Android Studio) aktivieren

NestedScrollView mgScrollView = (NestedScrollView) findViewById(R.id.my_games_scroll_view); 
mgScrollView.setSmoothScrollingEnabled(true); 

Aber das hat es nicht erreichen. Ich habe mgScrollView.setVerticalScrollBarEnabled (true) getestet; um zu sehen, ob ich den Code sogar auf die rechte Ansicht angewendet habe, und so geschehen auch die Bildlaufleisten nicht. So, jetzt bin ich verwirrt, ob ich diese Methoden sogar auf die richtige Ansicht anwende, aber da ich keine anderen ScrollViews habe, bin ich nicht sicher, wo es sein sollte, wenn ich falsch bin. Ich weiß, dass ich Scrollbars in der XML selbst hinzufügen kann, aber ich habe keinen XML-Code für Inertial Scrolling gefunden. Gibt es eine Möglichkeit, Trägheit durch Java oder XML hinzuzufügen?

Hier ist der Code für content_my_games.xml, das ist, wo die Layouts für die Karten gehen (nicht mit activity_my_games.xml verwechselt werden, der Code für die CollapsingToolbarLayout und FAB beherbergt)

Dank

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/my_games_scroll_view" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
app:layout_behavior="@string/appbar_scrolling_view_behavior" 
tools:context="com.example.abhinav.sportswowandroid.MyGamesActivity" 
tools:showIn="@layout/activity_my_games"> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingLeft="16dp" 
    android:paddingRight="16dp" 
    android:paddingTop="16dp" 
    android:paddingBottom="16dp" 
    tools:context=".MyGamesActivity"> 

    <android.support.design.widget.CoordinatorLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:fitsSystemWindows="true" 
      tools:context=".MyGamesActivity" 
      /> 

    <android.support.v7.widget.RecyclerView 
      android:id="@+id/recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior" 
      /> 

    <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      /> 
    </RelativeLayout> 
</android.support.v4.widget.NestedScrollView> 

Antwort

4

Alte Frage, aber gerade in diese selbst gerannt. Dies löste es für mich:

RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view); 
recyclerView.setNestedScrollingEnabled(false);