Grid Layout on Android? - java

I'm looking to create a grid layout - a complicated version actually. Since I am new at Java (I have created some Android Applications) I don't really know how to do this.
Let me explain: I want a grid layout, that looks like this:
But, instead of having pictures and colours inside of each box of the grid.. I want to have a box with 3 apps that the user can change. Kind of like the bottom part of Aviate launcher.
Like this:
So basically, I would like to have a grid layout, that the user can resize each part of the grid, each grid have a 3 apps inside, and the user can redefine those apps.
So how can I do something like that?
Thanks in advance if you understand the question.

I could not understand clearly. But, if you are looking for Gridlayout, try http://developer.android.com/training/displaying-bitmaps/index.html
Or, if you want to make a widget try open source project like https://github.com/twotoasters/HorizontalImageScroller-Android

Related

Android Studio: Group elements together

I am fairly new to android studio and I am trying to make a car rental app for a university project.
I designed an app which has a horizontal slider containing blocks of different cars however I am unsure on how I would do this, I understand how the slider works and how to add elements to it.
I have a linear layout within the horizontal slider which will contain all of the blocks but I am unsure how to make a block of elements. Within the block it should have two buttons, an image and some text. Here is a picture of the design.
As you can see the available blocks are surrounded by a square. this is what I want, a small container which surrounds my data. Sort of like a div box in html.
Is there a way to do this?
Please just point me in the correct direction!
Many thanks!
It seems like cardviews can handle most of the grouping you want to do. I would reccomend looking into them because they incorporate a lot of material design components right out of the box.
https://developer.android.com/guide/topics/ui/layout/cardview

What Box like view should I use?

I'm trying to create an app using Android Studio, and I want to use some type of expandable box, where I'll have an indefinite number shown like in a stack, and when clicking on the left side icon, the selected box opens up to show more info.
The basic idea of what I'm searching for:
Would anyone know about something like that??
Thanks in advance.
If I understand it well, what you're looking for is a recyclerview (for the indefinite number of row) and an accordion widget to open close your content.
I will suggest your to look at these projects:
https://github.com/hgDendi/ExpandableRecyclerView
https://android.jlelse.eu/get-expandable-recyclerview-in-a-simple-way-8946046b4573
which present all requirements you need.
And here is an similar question/answer : https://stackoverflow.com/a/10313432/6809926
The google search I made : android accordion recyclerview example.

UI not aligning

I am using LibGDX and Scene2D to create a simple menu for my game.
Here is a simple example that works for me:
table.add(gameLogo).row();
table.add(button1).row();
table.add(button2).row();
table.add(button3).row();
I didn't include the irrelevant code(including the table into the stage for example).
If I don't include .row() to each object that I add to the table, then the menu isn't aligning to the center, which is very odd, for example:
table.add(gameLogo).row();
table.add(button1);
table.add(button2).row();
table.add(button3);
Why is the menu behaving like that? should I use more tables or add some HorizontalGroups perhaps?
If you need any additional information, or images I can provide, although it does the same for even the simplest menu implemention possible with LibGDX and Scene2d.
This is a colspan problem.
Looking at your code, this is what you are currently doing :
I assume that you would like to display your menu like that :
In order to do that, as you can see, you need to set the colspan size of your gamelogo to 2, so that it will take as much size as 2 regular cells.
So, to achieve this result, your code should be :
table.add(gameLogo).colspan(2).center().row();
table.add(button1);
table.add(button2).row();
table.add(button3);
The align(Align.center) or center() methods will not work alone, since these methods are only used to align the widget inside it's own cell.
If you experience more problems with libgdx ui table, remember that you can enable a debug renderer to display the cells border :
table.setDebug(true);

Gather parts from layout, java android

Im pretty new at programming android and this is my problem:
I have a layout page that i have alot of information on, including buttons and textedits. Now i want to split it up in different parts, without having to create different layouts for every headline. So for example, if i choose to see "Information 3" i want to hide everything else on the layout except the "information 3 text/buttons/textedits".
Is it possible to do this? Because i really dont have time for making a new layout for every headline, and i dont want to show every headline at the same time. (I want to keep all information/data in the same layout file)
Maybe there is a smarter way to do it? Thanks in advance!
/Erik
You can call view.setVisibility(View.GONE) if you want to remove it from the layout. you can search some more questions like these:
hide/show on click of Button
how-to-show-hide-grouped-views
Try these and if u need more help then let me know

How to create something similar to JFileChooser in Java?

I am trying to make a frame similar to a JFileChooser. I have a scrollpane and 2 toggle buttons, one for list view, and other for icons view. I will be using CardLayout on the scrollpane. However, I don't know where to begin. I would like to know a good approach on this matter. How do I design the 2 panels that will be put over the scrollpane?
Something similar is the GroupBox in C# forms.
If you want to create "something similar to JFileChooser" why not to take a look on code of JFileChooser itself? You can find JDK source in file src.zip under your JDK directory.
See File Browser GUI for some tips.
I need to know how to create custom views. For example, for the listView option, I will be able to create a Jlist(i think) that will be spread out horizontally on multiple columns. For iconsView i will have some thumbnails that will be displayed vretically on multiple rows, etc.
For the detail view I'd tend to use a JTable. 'horizontally in multiple columns' can be done using a list and setLayoutOrientation(int).

Categories

Resources