Layout scrolling ripple effect - java

How could this scrolling behavior be accomplished?
Screenshot
To be specific, I need the wave effect to be shown whenever I try to scroll and reach the limit of a layout. Is there some property that I can tweak?

To get this wave effect, use any horizontally or vertically scrollable view as a container layout in your layout XML.
For example: ScrollView, HorizontalScrollView, NestedScrollView
List and Grid layouts like ListView, RecyclerView also has this scrolling effect.

Related

How to resize image as I scroll?

I have a ScrollView in which I have inserted a ConstraintLayout that contains a fullscreen ImageView and some other components below it.
What I want is for the image to shrink in height (to a certain limit) whenever I scroll down.
Here's an example of what I'm seeking: https://imgur.com/rlOr0HA
As for resizing, after some research I figured I'd have to create a LayoutParams object and then affect it to the ImageView. No problem there.
But as for detecting the scroll event, I've had some trouble. I tried the setOnScrollChangeListener on my ScrollView, but the problem is that it requires an API level of at least 23. So I wonder if there is another solution that works for lower levels as well.
Another problem I'm having is how to make the resizing proportionate to how much the user has scrolled.
You are looking to do the coordinator layout with a collapsing toolbar. This is built into android and you do not need any code changes. The inflater will inflate the layout and everything will work.
In your xml layout file you will need
<coordinatorlayout
<Appbar layout
<collapsingtoolbar
<ImageView> <-- your image goes here
/collapsingtoolbar
/Appbar layout
/coordinatorlayout
<nestedscrollview
<textview> <--Your content that moves up goes here
/nestedscrollview
<floating action button> <-- your example shows one of these buttons but its optional

List view with horizontal scroll

I am using custom list view with base adapter. The width of row is longer than screen. But I am not getting horizontal scroll bar like automatic vertical scrollbar. Do I need to specify any extra attribute? I tried with putting listview in horizontal scroll view but still no success. How should I achieve this?
Thanx in advance.
You might just need to use android:layout_width="wrap_content" in your horizontal scroll. You should also show your XML layout in case it is just some other minor change, like having the list view inside the horizontal scroll view.
As a side note, you won't get a horizontal scroll bar but the views inside the horizontal scroll view will slide left/right if their width is wider than the screen.

How to set the contents of a vertical scrollview depending on what button is chosen from a horizontal scroll above?

I was just wondering if any of you guys could give me a heads up as to what this involves?
I have used ScrollViews, I know they need a LinearLayout to scroll through and that isn't the problem.
It is that there is a dynamic horizontal ScrollView containing several buttons with buttons can be added/removed.
I also have a vertical scrollview.
The GOAL is to set the contents of the vertical ScrollView depending on which button is pressed in the above horizontal ScrolLView.
Any direction/insight would be appreciated.
Cheers
In ur Horizontal scroll view U have to set tag for individual views. Then in on click event of a view u can populate the vertical scroll by required data. I thinks for ur vertical scroll u can use the listview. It will be easy to handle. Also if ur horizontal things are in more numbers then its better to use the ListView for that even..

Setting Layout Parameters Programmatically

I'm trying to add a scroll view inside another scroll view.
It should look like is this:
scroll view
linear layout
myprogramaticscroll view
myprogramticlinear layout
myprogramticbutton
end button
end layout
end scroll
end linear
end scroll
I'm trying to add scroll views inside of that. It goes in there, but I need to know how to set parameters correctly so I can see the whole button I have inside of my scroll view. I only see part of it, and I need to set the programatic linear layout and scroll view's width height and id. How do I do this? This is what I have so far:
//the layout I'm putting my scrollview/linearlayout/button in
LinearLayout l = (LinearLayout) findViewById(R.id.linearLayoutFavorites);
ScrollView scroll = new ScrollView(this);
LinearLayout nl = new LinearLayout(this);
ImageButton yourButton = new ImageButton(this);
nl.addView(yourButton);
scroll.addView(nl);
l.addView(scroll);
You CAN'T put a scroll view inside another scroll view, that behavior would be odd, and Android would not know how to handle your scroll on the views.
For setting layout parameters, take a look at ViewGroup.LayoutParams, there're actually quite a few subclasses of ViewGroup.LayoutParams, which are for setting layout parameters for different kinds of layouts.
You can use a Scrollview in an another Scrollview. But this is not suggestible. It will be an issue to both the user and android OS. It will leads to Memory issues and also touch issues while scrolling the views. If you are expecting the Two scrolls (Horizontal and Vertical) at a time, then it is preferble to go for TwoDSCrollView
If you want to set the Layoutparams you should look at ViewGroup.LayoutParams.
If you want to set width and height then no need to set the Layoutparams. You can get the existing params by using getLayoutParams() for the view and set width and height to that params.
If you want to place vertical in vertical scroll or horizontal in horizontal scrollview the you should set the height of the internal scrollview height to the actual height of the total childs.

scroll view issue Android

I am adding layouts programmatically.I have added a scrollview as a parent layout and a combination of horizontal and vertical linearlayouts when I add a list view in the scrollview I am getting an issue that my UI is not taking full screen although the listview height is set to fill parent .There is a blank space added at the bottom and the height of the listview gets very small .I haven't find the reason why it's happening, is it a bug in android for scrollview ?
fill_parent won't work. Try setting android:fillViewport="true".
Without any code, I'd have to take a guess and say that your ScrollView is not set to fill_parent.
Try using layout editor in Eclipse or the hierachyviewer that ships with the Android SDK to examine your layout in the emulator and see which view is not filling the screen.

Categories