Я использую обычный recyclerview
и устанавливаю LinearLayoutManager.HORIZONTAL
, теперь, когда я нажимаю кнопку, recyclerview
должно расширяться до вертикального, и если я снова нажимаю на кнопку, он снова должен вернуться в горизонтальное recylerview
.
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="horizontal"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/topCategoryTxt" />
onButtonClick
if (LinearLayoutManager.HORIZONTAL == 0) {
layoutManager = new LinearLayoutManager(HomeScreen.this, LinearLayoutManager.VERTICAL, false);
recyclerview.setLayoutManager(layoutManager);
recyclerview.setAdapter(popularItemsAdapter);
adapter.notifyDataSetChanged();
}else{
layoutManager = new LinearLayoutManager(HomeScreen.this, LinearLayoutManager.HORIZONTAL, false);
recyclerview.setLayoutManager(layoutManager);
recyclerview.setAdapter(popularItemsAdapter);
adapter.notifyDataSetChanged();
}
Состояние всегда равно 0 как изменить его динамически Спасибо