How to scroll RecyclerView item beyond the boundaries - android

I want to scroll item beyond the boundaries.
I have attached image for reference.
Please help.

You can do this easily by not making the RecyclerView a child of the view that draws the white background. Simply make them both children of a parent that is the full width of the screen, with the RecyclerView on top. That way the RecyclerView will scroll the full width of the screen, and the background will, separately, be drawn where you want it.

Related

Make middle View not push other view outside of bounds

I have multiple TextViews inside a horizontal LinearLayout and i need the middle text view to have ellipse=middle so that when the middle text is long enough, it pushes on both sides but the other views don't go out of bounds, but instead the middle TextView shows the '..."
Here's how it should look.
Setting the items normally, wrap_content for all in a horizontal LinearLayout will make the at ASAP text be pushed outside of the screen on Android (the above screens are from the iOS app).
Any ideas on how to accomplish this? Perhaps with a ConstraintLayout somehow ?!
Yes, i would recommend a ConstraintLayout. Top item to the top of the view, bottom item to thr bottom of the view then the middle item attached to these two views. You could also use barriers.

Image Zoom In and Out with Recycler View Android

I am trying to implement a Recycler View in which the first item covers at-least half of the screen. This item has an image set as a background.
The behavior that i want to achieve is: when user scrolls upward the recycler view, the image should zoom in, and when user scrolls it downward, the image should zoom out and should be in original dimension as soon as the first item is completely visible.
I have tried using setScale() property on imageView but it's not working as expected. Please help!
Keep the first item in CollapsingToolbarLayout instead of placing it in RecyclerView and wrap both the views in CoordinatorLayout.
Then in CollapsingToolbarLayout add parallax effect using attribute collapseMode="parallax"
Finally, bound the RecyclerView scroll behavior to CollapsingToolbarLayout using property layout_behavior="#string/appbar_scrolling_view_behavior".

Android Resize nested horizontal recyclerview inside of scrollview, when user scrolls

I have an horizontal carousel that is embedded in a vertical scrollview.
I want to resize the content of the carousel once the user scrolls, so that the content will be collapsed when the user scrolls, and expanded when the user returns to the top (similar to what happens on material toolbar)
I know how to resize the carousel, but I'm not sure on how to notify the carousel views the new height, so that they can adapt their content to the new height.
Is there an standard way to do this?
My first thoughts are:
1) Make the carousel's height static, and change it on scroll. Then have the views implement onLayoutChangeListener or onSizeChange to make the change.
2) Make the carousel's height wrap_content (as it is now), and send the scroll event directly to the carousel views so that they change their own height (I'm not sure on how to do this)

Drag and Drop view outside of Recyclerview

What I want to achieve: I want to have a view inside a scrollable layout (Recyclerview with GridlayoutManager) with tiles (Views) in it. Dragging and dropping an item inside of the RecyclerView should adjust the position of the icon and swap with the other elements. When a drag starts, an icon above the RecyclerView will change to a trash icon and dragging the view to this icon will delete it from this RecyclerView.
I tried this excellent tutorial, but I didn't find a way how to handle dragging outside of the Recyclerview as the ItemTouchHelper.Callback uses only Recycler.ViewHolder elements as possible targets.
The method interpolateOutOfBoundsScroll() gives feedback if the view moves out of the boundaries, but will only give back the total size that is offscreen, but no coordinates. Also, trying to drag the view out of the Recyclerview always results in cutting of the View where it passes the borders of the Recyclerview.
Does anyone have an idea how I could achieve this effect?
You can achieve this simply by set this attribute for the parent of the RecyclerView:
android:clipChildren="false"
Edit: thank Adam Katz, I don't know why but sometimes you have to add this to the RecyclerView to make it work:
android:clipToPadding="false"
You are bound by the RecyclerView boundries. You have several options:
Make the RecyclerView's layout height to match_parent and to be on top of your upper view (is it a Toolbar?) and add a sticky header of the same size and have an empty transparent layout. That way you could drag ther and see the item floating over there.
Instead of dragging an item to a garbage can icon which is located too close to a legitemate upper-right item, make a long click to select the item (and apply a signal like a check mark or a red mask) and make the garbage can appear and delete uppon click (and maybe allow multi item deleting)

Android check either scrollview is scrollable or not

In my app I have a scroll view with n number of data to be listed out. There are two buttons one is named as UP placed above scroll view and the other is DOWN placed below scroll view.
Using the UP and DOWN buttons the list of views can be scrolled.
When the scroll bar is in top the Up button will be invisible and when the scroll bar reaches the bottom the DOWN button will become invisible, I have written logic for this using the getScrollX() method.
Now my problem is when there is very few data for example 3, the scroll bar will not be visible and the layout cannot be scrolled, in such a case both the UP and DOWN buttons need to be in invisible. How to do this, please suggest me a way?
You can try and use a ViewTreeObserver to check the dimension of the View inside your ScrollView. If the dimension exceeds a certain limit (such as the screen size), the ScrollView will be scrollable. See this preview SO answer for more details. Hope that helps!

Categories

Resources