How do i auto adjust my item positions in a layout in android?
up vote
0
down vote
favorite
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
add a comment |
up vote
0
down vote
favorite
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 Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
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
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
edited Nov 22 at 10:03
asked Nov 22 at 8:28
Muhammad Abdullah
237
237
Use Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52
add a comment |
Use Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52
Use Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
Use Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
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)
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
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)
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
add a comment |
up vote
0
down vote
accepted
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)
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
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)
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)
answered Nov 22 at 9:02
ABr
18017
18017
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
add a comment |
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
Here is the problem with that. If i have only one item in my list. whatever layout manager i use. It will show at the 1st position of that layout accordingly, but what i want is to show that item in the center of my fragment. Hope now you understand what i want to achieve.
– Muhammad Abdullah
Nov 22 at 9:54
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
so what is the total number of items. Is it unknown?
– ABr
Nov 22 at 10:03
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
Total items are 10, But i have to show them depending upon which item i need. it can be all 10 or just 1 or any number in between.
– Muhammad Abdullah
Nov 22 at 10:05
1
1
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
so you can change the spancount to 1 when the listsize is 1, I think that will move the item to the center
– ABr
Nov 22 at 10:17
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
Oh dear . How could i miss that . That worked .. Thanks.
– Muhammad Abdullah
Nov 22 at 12:08
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426684%2fhow-do-i-auto-adjust-my-item-positions-in-a-layout-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Use Gridview or RecyclerView with GridLayoutManager and inflate items dynamically.
– rajesh
Nov 22 at 9:16
@rajesh Ive tried that but if there is only 1 card in my list then it will show that card at the position of 1st row and 1st column but what i want is that it should move to the center itself.
– Muhammad Abdullah
Nov 22 at 9:52