yarolegovich / DiscreteScrollView

A scrollable list of items that centers the current element and provides easy-to-use APIs for cool item animations.
5.78k stars 783 forks source link

DiscreteScrollView doesn't show for the first time #167

Open samkazmi opened 5 years ago

samkazmi commented 5 years ago

Having a weird issue Screenshot_20190503-123539 The RecyclerView Doesn't show for the first time when activity is open But when i open the side menu (which is done in motionLayout) RecyclerView show up..

<com.yarolegovich.discretescrollview.DiscreteScrollView
            android:id="@+id/rvSmallList"
            android:layout_width="match_parent"
            android:layout_height="176dp"
            android:layout_alignParentBottom="true"
            android:layout_marginBottom="16dp"
            app:dsv_orientation="horizontal"
            tools:listitem="@layout/venue_item_small" />

ItemView is this `<?xml version="1.0" encoding="utf-8"?>

` Inside fragment ``` @SuppressLint("ClickableViewAccessibility") override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) binding.rvSmallList.setOrientation(DSVOrientation.HORIZONTAL) binding.rvSmallList.setOffscreenItems(2) binding.rvSmallList.setOverScrollEnabled(false) binding.rvSmallList.setSlideOnFling(true) binding.rvSmallList.setSlideOnFlingThreshold(2100) binding.rvSmallList.setItemTransformer(ScaleTransformer.Builder() .setMaxScale(1f) .setMinScale(0.9f) .setPivotX(Pivot.X.CENTER) // CENTER is a default one .setPivotY(Pivot.Y.CENTER) // CENTER is a default one .build()) binding.rvSmallList.adapter = VenueAdapter(vm.venueListSmall) } ``` adapter is pretty standard ``` class VenueAdapter(private val items: MutableList = ArrayList()) RecyclerView.Adapter() { fun updateList(items: MutableList) { this.items.clear() this.items.addAll(items) notifyDataSetChanged() } override fun getItemCount() = items.size override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ItemViewHolder { return ItemViewHolder(VenueItemSmallBinding.inflate(LayoutInflater.from(parent.context), parent, false) ) } override fun onBindViewHolder(holder: ItemViewHolder, position: Int) { holder.bind(getItem(position)) } private fun getItem(position: Int) = items[position] inner class ItemViewHolder internal constructor(private val binding: VenueItemSmallBinding) : RecyclerView.ViewHolder(binding.root) { val vm = VenueItemViewModel() init { binding.vm = vm binding.executePendingBindings() } internal fun bind(item: VenueItem) { // vm.venueItem.set(item) // binding.executePendingBindings() } } } ```
death14stroke commented 5 years ago

I am having the same issue. The onItemChangedListener works perfectly fine when you swipe on the screen but the view doesn't show. I also tried setting visibility in code but still, it doesn't show.

jjmins commented 4 years ago

I have this problem in Fragment.