Show item in center of gridview android - android

I am designing an app like foody, i have 5 item, put it in a gridview and set android:numColumns="3" . but in the second line, the items doesn't appear in center of the gridview row. i have tried some solution but nothing changed. Is anyone here used to deal with it, please give me your solution.

Related

How do i auto adjust my item positions in a layout in android?

This is my Current Layout
I'm stuck in this issue for a couple of days now. As you can see in the image above. There are 10 items below those 3 buttons. Ignore the buttons please. 9 items are visible and 1 item is below them. its a ScrollView. What i want to do is to position all those 10 items according to each other so when i hide one or more items, the rest positions themselves accordingly. for example if i hide the 3 items from the 3rd row then the item on the 4th row comes into the 3rd row in first column, and if i hide all the items except 1 or two then they should place themselves in a single row next to each other. How can i achieve that. I have tried several layouts, maybe i have missed something but i haven't been able to achieve the auto adjust part with any layout. Any help would be highly appreciated,i just want to know what layout or what can help me to achieve this goal ?
So if i hide 2 items from these 10 items,Then it should look like this.
This is what i want to achieve
but if there is only one item then it should look like this.
If just one item then it should look like this
Use a RecyclerView. You can add and delete views inside RecyclerView with layout animations.It's easy than changing the visibility. please check it(Don't know what's your need)

How to set full row section view for gridview?

I have tried and worked for listview with section view between list items and it works fine for me .
When I tried for gridview it is showing till the each item width not full row because obviously gridview comes with 2 or more items in a row .
So I want to make full row as section item between grid view items .
I searched elsewhere before posting here so can anyone help me ??
I don't think you can do that with GridView widget because it works in terms of columns. You can hack it with adding 3 Views in a row if that will work for you, but it will have obvious drawbacks such as you won't be able to put a text there that will take more that 1/3 of the screen width.
Use RecyclerView vs StaggeredGridLayoutManager instead: http://enoent.fr/blog/2015/01/18/recyclerview-basics/

Custom GridView's Last row items not showing fully

In My application I have to show all List Items in GridView and then while scroll down the GridView it needed to scroll the upper View(top of GridView) also along with Grid.For this purpose I have used HeaderGridView Add a Header to a GridView (Android). What I needed is working fine but the GridView's last row items are not viewing fully as like attached image.So,anyone please help me to solve this issue.
This is the default property of the gridview. It will show as like that only. If you need it in your own way, then you can solve it only by customizing the gridview by displaying the items in the gridview according to the screen height. This is only just a hint to solve your problem. So Please check this and if you doesn't got solution, please let me know.
Android gridview adjusting to screen size
android How to stretch rows in the gridview to fill screen?
How to make customAdapter fill gridview height
I think this links may give you some guidelines.

how to scroll to a particular screen location without actually scrolling

I have a scrollview inside which I have 5 imageviews say IMV1,IMV2...IMV5 . Now on scrolling,one by one all imageviews are shown in device screen. Now I have a drawer with 5 buttons say 1,2 ..5.
Now take us a scenario,
Currently I am on first imageview. Now when I click on button 5 in the drawer.
I need IMV5 to show on the screen without scrolling.It can be obtained
through smoothScrollBy/scrollTo to y equal to 5*screenHeight. But here it
scrolls through all intermediate imageviews.
Please note,I don't wish to affect scroll feature.For above example,
After I reach IMV5,when I scroll up,it should scroll to IMV4 and so on.
Is there any way to obtain it .Please suggest.
Thanks In Advance.
P.S. If you need some more clarification,please let me know.
You can achieve this easily using a ListView instead of ScrollView.
What you can do is:-
Add all the imageviews to a ListView.
This will fulfill your scrolling requirement, as ListView automatically handles scrolling if its content's size is grater than the screen size.
Now use the listView.setSelection(position) on click of the buttons.
It will scroll to the selected imageview without giving the scrolling effect
Hope this helps.
It can be achieved through ScrollView too.. All you need to do is get the View at that position. Then call requestFocus() on the obtained view.
For example:- If you press Button 5, then IMV5.requestFocus() will do it for you

Item in listview to be displayed in single line each

I have created a simple listview and added a few items in it. I am trying to add really long text in each item. I want this text to be displayed in single line only. the text that does not fit should fade in the corners. I have seen this kind of list in samsung galaxy s but somehow I am not able to achieve this. Can anyone help me?
Assuming you are using a TextView to provide the layout for each item in your ListView, just add these 2 properties in your TextView's layout definition xml:
android:fadingEdge="horizontal"
android:inputType="text"

Categories

Resources