android-recyclerview

TextView won't display after removing all recyclerview items

南楼画角 提交于 2021-02-07 10:12:07
问题 I've implemented two RecyclerView adapters, one is RecyclerViewAdapter and the other one is EmptyRecyclerViewAdapter. What I'm trying to do is to display the text Empty Text Here! whenever all the items are removed. Image 2 is working if there are no items yet in the list and it will display the text Empty Text Here! which is shown on Image 2 below however, If there are already items on the list and If i will remove all of the items in the list, Image 1 will be the result which displays

Item in RecyclerView not aligning as expected

眉间皱痕 提交于 2021-02-07 08:47:15
问题 My app has a chat activity which contains a recyclerview. This recyclerview contains two items that display the messages received by the user and the messages sent by the user. The messages received by the user is aligning from the left of the recyclerview as expected but the messages sent by the user is not aligning from the right of the recyclerview as expected. This is how it looks right now: The blue colored messages are the messages received and the gray colored messages are the messages

Item in RecyclerView not aligning as expected

為{幸葍}努か 提交于 2021-02-07 08:43:28
问题 My app has a chat activity which contains a recyclerview. This recyclerview contains two items that display the messages received by the user and the messages sent by the user. The messages received by the user is aligning from the left of the recyclerview as expected but the messages sent by the user is not aligning from the right of the recyclerview as expected. This is how it looks right now: The blue colored messages are the messages received and the gray colored messages are the messages

AsyncLayout Inflation for Recyclerview

北慕城南 提交于 2021-02-07 08:12:42
问题 I am working with two recyclerview in single screen(For android TV).Each recyclerview have complex layout item.And it's taking time to load.I worked with asynclayoutinflator in activities. AsyncLayoutInflater inflater = new AsyncLayoutInflater(this); inflater.inflate(R.layout.main, null, callback); I want to know whether there is any ways to achieve the same with recyclerview. Problem I am facing is onbindviewholder is getting called before asyncinflation finished. 回答1: import android.content

AsyncLayout Inflation for Recyclerview

匆匆过客 提交于 2021-02-07 08:08:40
问题 I am working with two recyclerview in single screen(For android TV).Each recyclerview have complex layout item.And it's taking time to load.I worked with asynclayoutinflator in activities. AsyncLayoutInflater inflater = new AsyncLayoutInflater(this); inflater.inflate(R.layout.main, null, callback); I want to know whether there is any ways to achieve the same with recyclerview. Problem I am facing is onbindviewholder is getting called before asyncinflation finished. 回答1: import android.content

ItemTouchHelper: Prevent out of bounds dragging

纵然是瞬间 提交于 2021-02-07 06:24:07
问题 I have a recycler view with ItemTouchHelper. It allows dragging the items. I want to limit the dragging to the bounds of recycler view - i.e. you can't just drag the view outside the container, so that it disappears. I tried checking the absolute coordinates like this: @Override public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { recyclerView.getLocationOnScreen(pos); int rvY = pos[1

ConstraintLayout: Unable to scale image to fit a ratio in RecyclerView

独自空忆成欢 提交于 2021-02-07 05:27:08
问题 I have a recycler view with StaggeredGridLayoutManager. Within in I have custom items/views. Each item is defined as a ConstraintLayout where there is an image which is supposed to have a constant aspect ratio. But the image is to still be able to scale to fit the width of each span. And then the height should be adjusted according to the ratio. But somehow the images are not maintaining the aspect ratio. Here are the xml files and code to create the recycler view: item.xml <?xml version="1.0

ConstraintLayout: Unable to scale image to fit a ratio in RecyclerView

喜夏-厌秋 提交于 2021-02-07 05:27:05
问题 I have a recycler view with StaggeredGridLayoutManager. Within in I have custom items/views. Each item is defined as a ConstraintLayout where there is an image which is supposed to have a constant aspect ratio. But the image is to still be able to scale to fit the width of each span. And then the height should be adjusted according to the ratio. But somehow the images are not maintaining the aspect ratio. Here are the xml files and code to create the recycler view: item.xml <?xml version="1.0

Implement Asymmetrical Grid Layout Manager Like Instagram Search

我只是一个虾纸丫 提交于 2021-02-07 04:29:15
问题 I Created a RecyclerView And Set layoutManager Of My Adapter To GridLayout . But I Want GridLayout Like Instagram Search below image, I Want A GridView Like This : Please Help Me . Thanks . i tried SpanSizeLookup But i Have Still My Problem And i Cant Control My Items to laying out exactly that way . . . 回答1: please take a look this answer and for show Your list in Span val manager = SpannedGridLayoutManager(object : SpannedGridLayoutManager.GridSpanLookup{ override fun getSpanInfo(position:

RecyclerView not recycling views if the view count is small

二次信任 提交于 2021-02-07 02:33:14
问题 I've been dealing with a strange behavior in Recycler View, if the view count in the adapter is small, in my case with size 5, the views are not being recycled and onBindViewHolder is not called when the view is scrolled back to screen. If i increase the size to 10 views for example, then recycling starts working and onBindViewHolder is called every time a view enters the screen. XML <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipeRefresh" android:layout_width="wrap