android-recyclerview

How to use RecyclerView.scrollToPosition() to move the position to the top of current view?

北慕城南 提交于 2019-12-17 15:36:37
问题 The RecyclerView.scrollToPosition() is extremely strange. for example, supposed a RecyclerView named "rv" . if now item 10 is under the current RecyclerView , call rv.scrollToPosition(10) , the RecyclerView will scroll item 10 to bottom. if now item 10 is in the current RecyclerView , call rv.scrollToPosition(10) , there won't be any scrolling, nothing will be done. if now item 10 is on the top of the current RecyclerView , call rv.scrollToPosition(10) , the RecyclerView will scroll item 10

Is there a callback for when RecyclerView has finished showing its items after I've set it with an adapter?

前提是你 提交于 2019-12-17 15:29:47
问题 Background I've made a library that shows a fast-scroller for RecyclerView (here, in case anyone wants), and I want to decide when to show and when to hide the fast-scroller. I think a nice decision would be that if there are items that aren't shown on the screen (or there are a lot of them that do not appear), after the RecyclerView finished its layout process, I would set the fast-scroller to be visible, and if all items are already shown, there is no need for it to be shown. The problem I

Adding a colored background with text/icon under swiped row when using Android's RecyclerView

你离开我真会死。 提交于 2019-12-17 15:26:58
问题 EDIT: The real problem was that my LinearLayout was wrapped in another layout, which caused the incorrect behavior. The accepted answer by Sanvywell has a better, more complete example of how to draw a color under swiped view than the code snippet I provided in the question. Now that RecyclerView widget has native support for row swiping with the help of ItemTouchHelper class, I'm attempting to use it in an app where rows will behave similarly to Google's Inbox app. That is, swiping to the

Android - Swipe to delete RecyclerView

℡╲_俬逩灬. 提交于 2019-12-17 15:22:18
问题 I am trying to implement swipe to delete the same as Gmail app "Swipe to archive": I have tried many tutorials but none of them works as fast as gmail, I prefer to not work on external library. How can i do it? Edit: My code so far- ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { //

Android - Swipe to delete RecyclerView

南楼画角 提交于 2019-12-17 15:18:27
问题 I am trying to implement swipe to delete the same as Gmail app "Swipe to archive": I have tried many tutorials but none of them works as fast as gmail, I prefer to not work on external library. How can i do it? Edit: My code so far- ItemTouchHelper.SimpleCallback simpleItemTouchCallback = new ItemTouchHelper.SimpleCallback(0, ItemTouchHelper.LEFT | ItemTouchHelper.RIGHT) { public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) { //

Use Custom Layout in NavigationDrawer With Header And list

孤者浪人 提交于 2019-12-17 13:43:14
问题 How to do add custom layout in NavigationView and design my create custom NavigationView use material design,i want put my drawer icon to right and text left of it something like this 回答1: I Search too much and this is my experience that works fine at first create layout for header. its name is nav_header_main.xml then put it in layouts folders in res and put this code in it.. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

Use Custom Layout in NavigationDrawer With Header And list

狂风中的少年 提交于 2019-12-17 13:42:41
问题 How to do add custom layout in NavigationView and design my create custom NavigationView use material design,i want put my drawer icon to right and text left of it something like this 回答1: I Search too much and this is my experience that works fine at first create layout for header. its name is nav_header_main.xml then put it in layouts folders in res and put this code in it.. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

gradle dependency error in android

人走茶凉 提交于 2019-12-17 12:47:15
问题 In the following build.gradle, I added the configuration section to avoid double inclusion of support libraries. Support libraries are used in the main project and in the dependent projects like facebook sdk. Without the configuration section, I get "UNEXPECTED TOP-LEVEL EXCEPTION". Adding that configuration makes the error go away and the app all works fine. Now, I'm trying to add RecyclerView to my app and I get RecyclerView class not found while inflating the recyclerview (although it

Disable Scrolling in child Recyclerview android

做~自己de王妃 提交于 2019-12-17 10:42:32
问题 I have a layout consists of a Parent RecyclerView with a sub Recyclerview in it i know that it is not good to put a list inside another list but i have to so that i can use the sub list features like swiping and drag and drop My issue is that the child Recyclerview gain focus and stops the parent from scrolling if the touch point was on it simply i want if the touch was vertically on the child Recyclerview the parent scrolls up and down and if the touch was horizontal or a click then the

How to snap RecyclerView items so that every X items would be considered like a single unit to snap to?

…衆ロ難τιáo~ 提交于 2019-12-17 10:38:11
问题 Background It's possible to snap a RecyclerView to its center using : LinearSnapHelper().attachToRecyclerView(recyclerView) Example: MainActivity.kt class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val inflater = LayoutInflater.from(this) recyclerView.adapter = object : RecyclerView.Adapter<RecyclerView.ViewHolder>() { override fun onBindViewHolder(holder: RecyclerView