in my project i have 9 image buttons which must come in 3 rows and 3 columns each image must be given a label or text beneath it as explaining it so is it good to use GridLayout or which layout will be best suitable for this situation and please suggest tutorial on suggested layout.
thanks
Here you go with it.
I would suggest you to use TableLayout if you have fixed no of views and will not change however if there is a chance of your views to increase then use GridView it uses adapter which manages memory it self.
Here is a good link to start off
http://www.androidhive.info/2011/07/android-layouts-linear-layout-relative-layout-and-table-layout/
Best of Luck
Related
How to create Horizontal listview that has maximum of 3 row and more column it depends on the data just like in this picture
Link:https://i.stack.imgur.com/cUJjB.jpg
This is my concept don't mind the design i just want to know how to create that kind of list view
You can try FlexLayout.
FlexLayout is similar to the Xamarin.Forms StackLayout in that it can
arrange its children horizontally and vertically in a stack. However,
the FlexLayout is also capable of wrapping its children if there are
too many to fit in a single row or column, and also has many options
for orientation, alignment, and adapting to various screen sizes.
More information can be found in the official documentation.
Set the ItemsPanel of the ListView to a horizontal StackPanel.
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal"></StackPanel>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
From this question.
Edit: This solution may actually not work for you. If it doesn't work, take a look at this library. It might help you.
I'm trying to make some auto fill grid, but without know the width from every item. So, the width from child can be deferent in every row and every column. It only depends from a TextView.
I want something like this.
I'm tried with GridLayout and android:numColumns="auto_fit" but isn't what I'm looking for.
I also check this post but is basically same as GridLayout.
Anyone know some other solutions??
Flexbox-Layout is a project by Google to provide both a simple view and a RecyclerView layout manager that does what you want. https://github.com/google/flexbox-layout
I think the following tutorial might be a solution for the current problem u r facing
Tutorial
Hope it helps ;)
I'm trying to make the duolingo lesson list for fun because im a big fan of the app, im a beginner programmer.
basically id like your opinion on how you think they did it.
here is what it looks like
https://s-media-cache-ak0.pinimg.com/236x/a3/a8/65/a3a865c47153078e7004b74652af7757.jpg
I think it might be a scroll view and linear layout, then perhaps a class for each icon/progress/name combo that will change based on progress
I think a table layout might be an easier solution.
Check it out here: https://developer.android.com/guide/topics/ui/layout/grid.html
I figured out how to do it, you need to use a scrollView followed by a linearlayout.
Then you can programatically add in relative layouts as rows and in those relative layouts make another square relative layout and in that relative layout you stack up the stuff like image/text/progress
re: example http://www.youtube.com/watch?v=Ej--SFh963M
Similar to the above app, I am trying to create a scrolling list of images, like a Listview but with images only. (I also need to set it to fill a set height and width, say 85% of the height, 10% of the width of the screen). Is a one column Griview best? (I have had troubles in the past selecting the image height of a gridview programatically).
Any online tutorials precisely for this you have used?
If your view is going to have only one element per row, then the best and correct way of implementation is to use a ListView. The GridView should or can be used when there are going to be multiple elements per row. I believe the purpose of ListView satisfies its role for your need.
For creating a GridView with uneven rows similar to how Pinterest looks. Includes own OnItemClickListener and OnItemLongClickListener, selector, and fixed position restore. Check out this link, there is a library named "StaggeredGridView" : https://github.com/maurycyw/StaggeredGridViewDemo
As there is no text and only one column of buttons, it seems like I overlooked the obvious answer of using a scrollview of buttons, which is what I will go with. Thanks for your assistance.
I would like to create a grid of dots very much like in this game: https://play.google.com/store/apps/details?id=com.nerdyoctopus.gamedots&hl=en
The aim is for each dot to be touchable, so I can recognise where that particular dot is and other information about it.
I don't really know where to start. Do I want to create a custom View for a dot with all the information I want, and then create multiple versions of it? And then do I arrange them in a grid with the setTranslation() method, or would it be better to use LayoutParams with offsets?
If I created my own "Dot" that extended "View", then I could add a lot of different information/methods to it - I could theoretically have a changeColor() method. Is this the best way?
A GridView is not what I am thinking of (as far as I know) as it is basically a different style of ListView.
There are lots of questions here! I have looked at a number of questions here on StackOverflow and elsewhere, but none show/ explain how I should start.
I would use a TableLayout for this. A GridView is the equivalent of a ListView in a 'grid' form, with scrolling, view recycling and whatnot, and that is not what you need. A GridLayout, as Dalmas suggested, would be a much better option if you want to build a static grid, but in my experience it is not easy to distribute the available space equally between columns, and if you are going to need to alter the grid distribution during the game, a TableLayout is much easier to use.
For the dots, yes, a custom view with a configurable color would be the best way to go around it.
You should use a GridLayout. It will do exactly what you need. It is available through the android support library v7 : http://developer.android.com/tools/support-library/features.html#v7-gridlayout
It allows you to arrange views using a grid of rectangular cells.
For the dots, I would go with a custom dot view as you suggest, with a simple method to set the color. Don't store any data in the views if possible, it will make things much easier and flexible.