android-recyclerview

RecyclerView inside ScrollView, some items are not shown

Deadly 提交于 2019-12-30 05:46:08
问题 I had a RecyclerView in ScrollView like this: <ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <!--other stuff--> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <android.support.v7.widget.RecyclerView android:layout_width="match_parent" android:layout_height="wrap_content" android:visibility="gone"/> </LinearLayout> <!--other stuff--> </ScrollView> And the RecyclerView 's item is a RelativeLayout , inside of which

How to handle a lot of different view types in recyclerview viewholder

风流意气都作罢 提交于 2019-12-30 04:44:06
问题 What if I have 50 types of views? Should I have 50 static inner classes in my adapter? According to this answer, yes. My first thought was to move each viewholder inner class into a seperate public class, but they have to be static. So encapsulate each one into a public class, to make the inner class static? Are there any nicer alternatives? edit: code sample: So this would be a good solution? Doesn't this also kill performance? public class MainViewHolder extends DragSortAdapter.ViewHolder

NestedScrolling with NestedScrollView, RecyclerView (Horizontal), inside a CoordinatorLayout

拥有回忆 提交于 2019-12-30 04:05:20
问题 I have a UI design with CollapsingToolbarLayout, like following. <android.support.design.widget.AppBarLayout android:id="@+id/appbar" android:layout_width="match_parent" android:layout_height="@dimen/detail_backdrop_height" android:fitsSystemWindows="true" android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> <android.support.design.widget.CollapsingToolbarLayout android:id="@+id/collapsing_toolbar" android:layout_width="match_parent" android:layout_height="match_parent" android

How to sync scrolling first-positions of 2 RecyclerViews?

让人想犯罪 __ 提交于 2019-12-30 04:01:11
问题 Background I have 2 RecyclerView instances. One is horizontal, and the second is vertical. They both show the same data and have the same amount of items, but in different ways, and the cells are not necessary equal in size through each of them . I wish that scrolling in one will sync with the other, so that the first item that's shown on one, will always be shown on the other (as the first). The problem Even though I've succeeded making them sync (I just choose which one is the "master", to

What is the equivalent listview.setSelection in case of Recycler View

泄露秘密 提交于 2019-12-30 03:39:05
问题 In the case of a ListView if we want to make a particular item selected we use the setSelection method. How do we do this in case of RecyclerView ? 回答1: Use RecyclerView LayoutManager to scroll item at position recyclerView.getLayoutManager().scrollToPosition(position) 回答2: Check scrollToPositionWithOffset(int position, int offset) scrollToPositionWithOffset(5,0); from LinearLayoutManager Scroll to the specified adapter position with the given offset from resolved layout start. pass offset as

Horizontally center first item of RecyclerView

亡梦爱人 提交于 2019-12-30 03:21:05
问题 I want to use a RecyclerView to emulate the behavior of a MultiViewPager , in particular I'd like to have the selected item at the center of the screen, including the first and the last element . As you can see in this image, the first item is centered and this would be my expected result. What I did was to setup a RecyclerView with an horizontal LinearLayoutManager and a LinearSnapHelper . The problem with this solution is that the first and the last item will never be horizontally centered

Rendering Problems: java.lang.NullPointerException at android.support.v7.widget.RecyclerView in Android Studio 1.1.0

血红的双手。 提交于 2019-12-30 02:45:08
问题 I have recently updated android sdk to api 22 and android studio 1.1.0. After that I am getting rendering issues on RecyclerView. Here is what I am getting java.lang.NullPointerException at android.support.v7.widget.RecyclerView.computeVerticalScrollRange(RecyclerView.java:1216) at android.view.View.onDrawScrollBars(View.java:12943) at android.view.View.draw(View.java:15237) at android.support.v7.widget.RecyclerView.draw(RecyclerView.java:2440) at android.view.View.draw(View.java:15140) at

YouTubePlayerFragment inside ReyclerView

旧巷老猫 提交于 2019-12-30 02:02:27
问题 I have a RecyclerView with CardViews inside it. I want each CardView to have its own YouTubePlayerFragment. Even if they can't all be active at once, I can't even seem to instantiate the YouTubePlayerFragment in any CardView but the first in the RecyclerView. When clicking the button on the card that's supposed to set up the YouTubePlayerFragment, it always sets it up on the first card, even if I've clicked the second card. Is what I'm trying to do possible? Here are the relevant parts of

How to auto scroll up Recycler view in Android?

痴心易碎 提交于 2019-12-30 00:59:08
问题 I have developed some chat application where i can send and received messages. But the problem is whenever i send or receive messages the recycler view is not scrolling to top so that messages gets diplayed above the keypad. I have used the above mentioned recycler view android.support.v7.widget.RecyclerView . 回答1: On updating recyclerview try to run this code : recyclerView.post(new Runnable() { @Override public void run() { // Call smooth scroll recyclerView.smoothScrollToPosition(adapter

RecycleView set wrong height for items

纵然是瞬间 提交于 2019-12-30 00:58:09
问题 I search answer for me, but didn't find work answer for me. I got strange error in viewing my items in RecycleView : I use different view's for RecycleView. I try use this code: mLayoutManager.setAutoMeasureEnabled(true); // false doesn't work too But it doesn't help me. UPD 1 I forgot note this, sorry. When I start app, I have no errors (items like Normal on image) but when I started scroll my RecycleView I got problem) UPD 2 I return back to the compile 'com.android.support:recyclerview-v7