2016-12-14 6 views
0

У меня есть макет с RecyclerView с 5 TextViews и NestedScrollView является родительским макетом. Поэтому мне нужно прокрутить все 5 TextViews с помощью RecycleView. В соответствии с текущей реализацией прокручивается только RecycleView. Скажите, пожалуйста, как мне это достичь? Мой XML является:Как прокрутить другие виды с помощью recyclerView в Android?

<?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" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fillViewport="true" 
    android:focusableInTouchMode="true" 
    app:layout_behavior="com.evs.demo.layout.FixedScrollingViewBehavior"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      style="@style/ToolBarStyle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/md_deep_orange_500" 
      android:elevation="8dp" 
      android:minHeight="?attr/actionBarSize"> 

     </android.support.v7.widget.Toolbar> 


     <android.support.v7.widget.RecyclerView 
      android:id="@+id/my_recycler_view" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_margin="5dp" 
      android:layout_weight="1" 
      android:scrollbars="vertical" /> 
      <TextView 
       android:id="@+id/empty_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="No Records" /> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="No Records" /> 

      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="No Records" /> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="No Records" /> 
      <TextView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       android:text="No Records" /> 

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

ответ

0

Для правильной прокрутки вы можете изменить менеджер раскладки вы установили в кодировании для просмотра ресайклера. Я надеюсь, что это помогает.

RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity()) { 
    @Override 
    public boolean canScrollVertically() { 
     return false; 
    } 
}; 
recyclerView.setLayoutManager(layoutManager); 

Другое решение

попытка ниже кодов:

RecyclerView recycleView = (RecyclerView) findViewById(R.id.lastest_product_list); 
recycleView.setNestedScrollingEnabled(false); 

Вы можете изменить макет

<ScrollView> 
<LinearLayout> 
    <android.support.v7.widget.RecyclerView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/lastest_product_list" 
      android:nestedScrollingEnabled="false" 
      android:isScrollContainer="false"> 
    </android.support.v7.widget.RecyclerView> 
</LinearLayout> 
+0

Привет Новичок, я хочу scroll textview с видом Recycler, я могу обрабатывать прокрутку между nestedscrollview и recyclerview – Reena

+0

Вам нужно добавить textview как другую строку в ресайклере, и тогда я думаю, что вы сможете получить желаемый результат. [link] (https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView) –

+0

Я не хочу добавлять текстовое изображение в сторону RecyclerView – Reena

Смежные вопросы