I have a grid view which shows some items. The user can scroll down and up. I want to be able to show a button at the very end of the grid view when the user has scrolled to the end. This button will not show when the user is not at the bottom of the grid. How can this be done ?
When the user is not at the end, the grid should look like this
and upon reaching the end of the gridview, a button should be added as a footer to gridview.
Gridview doesn't allow you to add a footer view but you can program it.
take a look at this answer from Frank.
He has added a scrolllistner and only shows the button when you are getting close to the end.
Related
I am working on an android application where I need to show some offers in horizontal scroll view. These offers are in the form of clickable buttons.
Here is the list example:
Notes about this pic:
This is a horizontal scroll list of clickable buttons.
This list can have multiple buttons and at a time, we can show only 2 buttons with full width like shown in the pic.
Here is the 2nd pic:
Notes about this 2nd pic:
This show that one button is in the center.
What I want:
I want when user scroll the horizontal list then button that is displayed with full width in scroll view should animate to the center when user removes his hands from scrolling view. With that said, I can scroll by tapping and it should be smoothly but when I leave doing scrolling then the button that seems to come in center should be animated to center position like in 2nd image.
I tried this given solution but this works when I click on a button.
Android : Locating the item at center position of the screen after selecting it ,In the horizontalscrollview
This is exactly similar but I want the button in the center when I
leave doing scrolling.
Any help?
I have a recycler view which has its items in a card view. The recycler view gets its data from a sql database within the app . Now I want to implement two features to this recycler view items. First , whenever the individual cards are tapped , I want them to enlarge and display more data and should shrink back when tapped again. It is not like the case of expandable list view where it expands into a child list view. I want the height of the card to increase and just show some more information and buttons. Second I want the items to swipe left . I know there is a feature for that in recycler view , but I want to customise the swipe feature. Swipe from right should be locked , and when swiped from left , It should not go off list completely. It should show two buttons and should go off list only when one of the buttons is clicked. I have been looking , but there is no proper explaination anywhere. Please guide me through this process.
For your first question, set the adapter layout_height to wrap_content and set the buttons visibility to GONE. Implement the OnClick listener in the RecyclerView adapter and set the visibility of the buttons to VISIBLE if GONE and GONE if VISIBLE or use a boolean to alternate the visibility.
For your second question, this might help:
https://www.learn2crack.com/2016/02/custom-swipe-recyclerview.html
How can I make my Android SwipeableCardViews more like the IOS 7 mail app (swipe to show buttons)
https://github.com/daimajia/AndroidSwipeLayout
this pop up should bottom aligned and comes when I tap on any grid item and in the form of columns... like for 5 images first row should show 3 images and second row should show two..
I have tried with alert dialog, but it is coming in list view ...
i am trying with split action bar but it may contain only system images..
I have tried all possible things. but i am unable to get solution..
please help me...
Does any one know how to do that??????
You can set a touch listener to the grid view - setOnTouchListener.
Override method onTouch and implement your logic to show/hide the popup.
Remember a popup could also be a layout in your view for which you change the visibility from GONE to VISIBLE and viceversa. To have a better result do that with an animation (maybe fade + translate).
I am working in android application which is using listview to populate its data,In the design firstly list is shown with some of items, and on clicking on the cell it expands to show another part of the cell layout whose visiblity is "gone" on the creation of the cell.
Now if user clickes on the last cell of the listview it expands to show its invisible layout but that goes below the visible window of the screen.Now what i want to do is if on expanding the list cell its content goes below the visible window scroll listview up automatically to show complete cell.
Please suggest a best way how can i achieve it?
Try this, not sure if it will work, but give it a shot:
listView.scrollTo(0, listView.getHeight());
Let me know.
I have a requirement for my android application that a button is at the bottom end of the list. That is done on purpose so users have to scroll trough the entire list (and possibly see more answers). Therefore I added the button as a listview footer.
This all works fine but in some cases the list is too short (only 3-4 items in it) so the button will end up about midway of the screen. What I would like is that the button is at the end of the listview (so if enough items in the list, the user can only see the button when he scrolls down) but when the listview only contains a few items the button will fix itself to the bottom of the screen.
To give the idea I want:
onCreate() {
if (button.getyposition() > screen.getyposition()) { // example methodnames!
// Button at the bottom of the listview (many items)
}
else {
// Button at the bottom of the screen (few items in listview)
}
}
The point is, I don't know if it's possible and where to start. Could anyone give me some directions where to look or even better a piece of sample code? Thanks in advance!
EDIT:
I added a picture to clarify my problem. I hope this makes more sense!
Picture showing the button halfway on the screen http://niles11.dyndns.org/example.png
As you can see, it looks quite strange with the button halfway on the screen. I want the button to be at the bottom of the screen BUT (!) when the listview contains more items I want it to appear at the bottom of the listview (so at first, be off screen)
Hope this picture helps!
I understand you Issue. I have an ideal : you should inflate last item(position = array.size) as a button instead of normal view item.
if i am not wrong you want your listview on the whole screen with a button below.
make listview's height match_parent and android:layout_margingBottom="somedp"
and for button marginTop="-somedp" somedp shoulb same on both places...
Set the ListView height to fill_parent and add a Button as the footer using addFooterView()
If you have the requirement that you only show the Button when the List is scrolled to the end, then you can look at this post and use the logic to show/hide the footer view (ie, set View.GONE on the footer to hide it, and View.VISIBLE to show it)