overlapping problem in AdapterView - android

I am using AdapterView to have Custom List. But my Xml layout not only
contains that List. It also have some other elements like TextBox,
labels, ImageButton at the top and bottom. so when i scroll it up
and animation starts it also draw elements on that Top Part(Which
contains ImageButton and other stuff). so can some one tell me how can
i remove it ? another issue is it do not have scrool bar. can some one
tell me how can i add scroll bar in it ?

for adding scroll bar to the listView add this attribute to your listview in the xml
android:scrollbars="vertical"
Check the following link. here i mentioned a complete code to use listview properly. Using this we can achieve any listview behavior. We can embed animation also.
For controlling list View Behavior ensure the getView Method of your list is generating the vew dynamically and as per your requirements . Each time a list get scrolled . The getView Method get called for all the element in the view. Do account all these things.
Change ListView background - strange behaviour
Hope this help :)

Related

How to change gridview layout correctly while scrolling in android

I have a gridview in my android project which show some Items that fetch from. I use a custom adapter extends BaseAdapter and a custom layout for my gridview to show each item.
What I need is to change the gridview custom layout when a button click, I use a FloatingActionButton that when I click on that the layout change correctly, but the problem is when I am scrolling the gridview and click the FAB the gridview layout change but it render incorrectly !!!
What should I do to change layout correctly? Is there anyway to stop gridview from scrolling then change the layout?
P.S: I've used gridview.invalidate() method and some other methods like this but nothing works ! I also should mention that when the layout render incorrectly when I scroll up and down it became correct !
This should be very possible and easy using android's recycle view with it's layout manager. check up on their documentation https://developer.android.com/reference/android/support/v7/widget/RecyclerView.html

How to add Parallax Effects to List Item in android

I have an listview in my app, which displays list of images only. Now I want to add parallax effect for list items while scrolling the listview. I just now implemented listview only.
In a nutshell, you need to set a header to your ListView. This header will contain the image you want to apply a parallax on as well as the content that should go over (it usually is a classic ListView header but it could as well be something that looks like any element of your list).
The second main thing is to add a ScrollListener to your ListView, and create a custom ImageView (which overrides ImageView) that is able to receive how much your list has scrolled. In the onScroll callback, you can retrieve the first element of the list if it is visible, do a getTop() on it and send it to your custom ImageView.
You now have an ImageView that knows where it is on the screen even when your List scrolls. All you need to know is to translate the Y of your view (with either canvas.translate() or view.translate() depending on which SDK version you're working on).
I don't think it takes much more time than integrating a library and it works great!
I generally use ParallaxListView by Gnod. Check the below link
https://github.com/Gnod/ParallaxListView

How to make list view scroll above top item and under last item

I need to implement list view that must show selected item in the center of list view.
Is it possible?
The problem is that list view forbid scrolling before top item and after last item.
The only workaround here I found is to add several dummy header and bottom items and use setSelectionFromTop() method for right positioning.
Is there any other better way?
Thanks
You could use a circular ListView Check this thread on how to implement it
and use smoothScrollToPosition to bring your particular view to the center.
You shouldn't need to add multiple dummy list items. Just extend your Adapter and use a single blank dummy list item that you can programmatically adjust the size of based on the screen resolution of the device.

Trying to alternate between GridView & ListView leaving artifacts

I have an app whose default style is to present data in a GridView. When the user presses the Menu button they can choose to present the data as a ListView.
The problem is that once the first switch happens, it's as though the ListView is simply superimposed above the GridView. The GridView layout doesn't go away. I have to scroll with my finger a little bit before it disappears.
What I'm doing is basically setting another setContentView call to my XML file that defines the ListView. It's not just a simple matter of changing the adapters.
I am guessing that I need to completely destroy or remove my GridView--but how do I do this? Note that if I switch from ListView to GridView the problem remains.
Consider putting both in a ViewFlipper, rather than using setContentView().
for list
gridview.setNumColumns(1);
and for grid
gridview.setNumColumns(2);
What about playing with visibility?
When List is selected in menu, make gridview visibility to 'GONE',and list to 'VISIBLE'
and vice versa when Grid is selected in menu

how to scroll up when choose some item at item list in android?

I jave a list of item (linearlayout inside a scrollview where i add buttons vertically to linearlayout dynamically from the java code ) ? i need when i click on one button the item moves up (scroll up) , to make the item at the first of the screen ??!
Well I never did that, but from the ListView reference it seems pretty clear that set setSelectionFromTop is what you are searching for.
See also how-to-autoscroll-a-list-view-in-android

Categories

Resources