Я застрял в своей компоновке с большим количеством переработчиковПросмотров (4).
Если три рециркулятора имеют до 20 элементов в каждом, и они равны GONE
по умолчанию в xml, тогда четвертый переработчик имеет до 100-400 элементов (не более), которые динамически изменяются в коде, и по умолчанию он равен VISIBLE
.
I требуется для прокрутки (плавная прокрутка, c) всего меню (макета), включая все его элементы.
Я пытался NestedScrollView
, ScrollView
для всего макета, для частей макета, для recyclerViews.
Я пытался это для RecyclerView
: app:layout_behavior="@string/appbar_scrolling_view_behavior"
Я пытался:
layoutManager.setAutoMeasureEnabled(true); //deprecated
recyclerView.setNestedScrollingEnabled(false);
Я пытался android:descendantFocusability="blocksDescendants"
для Вложенного
Я пытался android:nestedScrollingEnabled="false"
для RecyclerView
Я пытался adapter.setHasStableIds(true);
Я пытался объединить все эти вещи из stackoverflow и других ресурсов.
I достиг прокрутки, которую я хочу, просто добавив NestedScrollView
после моего rootLayout
(не плавно, но работает корректно), но только в AVD, реальные устройства с оперативной памятью до 3 ГБ не могут не обрабатывать добавление NestedScrollView
- устройства получают бесконечный черный экран и пустые журналы.
Возможно, я пытался сделать что-то еще, и я забыл напечатать о них здесь. Прокомментируйте некоторые другие подобные исправления, и я отвечу.
Как мне добиться плавной прокрутки всех rootLayout
элементов?
Я знаю это правило о прокрутке представлений внутри других видов прокрутки, но мне нужно , чтобы прокрутить все мои прокручиваемые рециркуляторы.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:id="@+id/rootLayout"
android:background="@color/float_transparent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/LLMenu"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/gray21"
>
<RelativeLayout
android:id="@+id/RLTop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<View
android:id="@+id/BluecolorView"
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/colorBlue"
>
</View>
<View
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/white"
android:layout_below="@+id/BluecolorView"
>
</View>
<FrameLayout
android:id="@+id/FLIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
>
<ImageView
android:id="@+id/logoinmenu"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="@string/logo"
android:src="@drawable/logoicon"
>
</ImageView>
</FrameLayout>
</RelativeLayout>
<TextView
android:id="@+id/TVUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:textSize="@dimen/textViewTextSize"
android:text=""
android:layout_gravity="center"
android:textColor="@color/white"
>
</TextView>
<LinearLayout
android:id="@+id/LLAllM"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/LL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
>
<LinearLayout
android:id="@+id/LLIVandBTG"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="visible"
>
<ImageView />
<Button
android:id="@+id/BTGenresRV"
android:layout_width="match_parent"
android:layout_height="20dp"
android:background="@color/float_transparent"
android:text="@string/genres"
android:textAllCaps="false"
android:textColor="@color/white"
android:gravity="start|top"
android:layout_marginStart="5dp"
>
</Button>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RVGenresList"
android:layout_width="match_parent"
android:layout_height="150dp"
android:visibility="gone"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
Here are three more similar to "<LinearLayout android:id="@+id/LL" blocks...
</LinearLayout>
</LinearLayout>
</LinearLayout>
UPD:
I ' забыли добавить, что вся эта обработка фрагментом public class MenuFragment extends Fragment implements View.OnTouchListener
находится в ActivityName extends AppCompatActivity
UPD2:
частично исправлена добавив ScrollView
после rootLayout
и stati c height к переработчикам.
Посмотрим, может быть, это лучшее решение, и я предоставлю полный код в ответ.
UPD3: Это из-за wrap_content
и match_parent
Я не смог прокрутить так, как мне нужно.