I'm trying to make a dashboard like app to display real time data to a user in a vehicle with a layout similar to the included screenshot. I've tried googling for a direction to follow to try and mimic google's responsive grid columns design principle. However, I can't find any examples of that principle in practice on android. How would I go about implementing this type of design in android? Would you use Grid Layouts?
Ideally I'd like to be able to have a Grid Layout that has cells that are consistent in size that allow me to span a Card View across columns and rows but I don't know of a way to do this using a Grid layout. Any ideas?
Screenshot: https://gyazo.com/912c3414d9e8d46a1fa4eade54d620e6
Take a look at GridLayout. It will allow you to define a grid and to span columns/rows. I was also going to mention GridView, but I don't think that it allows spanning of cells.
Another possibility is FleboxLayout if you need more flexibility. TableLayout also permits spanning.
You can also build a grid layout directly with ConstraintLayout using the "GuideLine" object.
Those are four layouts that I would consider.
Related
I'm a flutter user trying out kotlin dev first time, but im kinda confused what the best alternatives for this type of layouts are.
I understand that I use recyclerview for a dynamic number of items. And since theres two dynamic ones (one for number of sets, one for each exercise). Do I use two nested recyclerviews?
It really depends what you're doing here. A RecyclerView is basically a list, so it's a good choice for a scrollable set of items - which it looks like your Exercises are. But how do you want to display those weights?
It's possible to make them scrollable, so some of them aren't visible on the screen (the categories on the Play Store act like this). For that you would need a nested scrolling view of some kind - could be a horizontal RecyclerView, or it could just be a ScrollView wrapped around a LinearLayout you throw views into.
But the other option you might want, is that for each Exercise, all of its weights are visible in a grid of some kind. No scrolling, all there up-front to see and poke at. So the first question is which of those do you want?
I'd assume it's this version - where you can easily visualise the contents - in which case you're not talking about nested lists, it's just one list, and each item contains a grid you can add things too. For that setup, there's GridLayout, TableLayout, and ConstraintLayout Flow (which acts like FlexBox if you're familiar with that). So in the layout for an item in your list, you have a container for stuff, and you put the stuff in it, and the container expands vertically as needed
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 have been developing android for a while and I have been facing many similar layouts to the one in screenshot (in both iOS and Android)
So what I would like to achieve is the different number of childs in each row.
Well, first I would like to ask is there a specific name for this layout type, it is not gridview although very close to it.
The structure seems like it can be populated with an adapter since all child buttons look alike
Any help, suggestion, solution or example library is much appreciated.
Taken from Foursquare for Android
Since there is a chance of more than two childs (as you said) therefore what i think is that you can't accommodate so many childs as they would not be visible unless the listview row is horizontally scrollable.......I think you can use gallery widget as an item of listview and then you can have different childs in each row... You can google about the gallery widget, instead of images add your custom layout as gallery item.
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.
I'm trying to design a table UI for my activity. I would like three columns and a fixed number of rows (so that the view fill all allotted space). Each of the cells should be clickable, and able to host standard widgets such as textview of buttons. I also want to control the scrolling (virtual grid with infinite up/down data). Pretty much something like the image below.
What is the recommended way of making a UI like this?
ListView?
TableLayout with dynamically added rows?
Custom class derived from View?
OpenGL?
I tried both 1 & 2, but so far have not been happy (hard to control height of each row). Any comments and code samples welcome.
Your app looks like it works with DB. If so TableLayout is not good to work with things like content providers/ loaders/ CursorAdapter…
Custom view is up to you but I think, based on the image, ListView is good enough. And let it manage the row height itself, that's not a big deal.
I'm not sure about OpenGL. For simple thing, I'd choose ListView/ GridView.