What are these element called? - java

I'm developing my first real app and found inspiration in Instagrams design.
I would like to know what the red and blue area is called and if these exist within androids own libraries so I can implement them.
I guessing that the blue area is something called carousel list/tab-list or button menu or maybe a lot of radio buttons? If you, for example, press on the Juno filter, the list will automatically scroll towards left, so you can see the rest.

The red rectangle is horizontalscrollview and the blue rectangle is LinearLayout with three child.

there are multiple options but I think the blue box in LinearLayout and Red one might be a simple scrollview

Related

Design decision for custom view

I want to design a custom card view which displays information about a duel in an android app. Here is a screenshot of what the view looks like right now.
The image and the green button should be clickable, however, this design is currently done in one custom view extending CardView. The green button is a Rectangle and the polygon is a filled Path which overlays the button.
Because I have done everything in one onDraw() method, there is no onClick() method for solely the button or solely the image. Is there any clever way to do this? Maybe I'm conceptually wrong somewhere?
My thoughts so far:
Have a transparent button on top of the green button in the xml
Maybe there is a way to include a button in the onDraw() method
Make the whole view clickable and include the image in the xml
This is how I solved it now. I changed the custom view to only display the skewed rectangle. The other resources were created in a seperate xml file. With an <include />, I was able to place the rectangle over the button.

Draggable overlay that can go offscreen?

I have created an overlay menu that is a rectangle.
It displays on top of everything else while active. All other apps, the home screen, etc.
If you click anywhere outside of this rectangle your click hits
whatever is visible.
If you click the red part it allows you to drag the menu around the
screen. Clicking the green part performs some function.
I have created this rectangle from inflating layout xml. The rectangle itself is a relativeLayout and the green and red parts are both imageView children.
Since I'm unable to move the relativeView off screen and since the background needs to be clickable my only solution was to calculate margins and apply them to the relative view to imitate the desired effect.
However, the code to calculate these margins is almost 50 lines and fairly complex and hard to understand at a glance if someone else needs to refactor. I can post the code but I don't believe it's relevant to the actual problem's context.
Is there a much simpler way to do this that I'm missing? Is my approach wrong?
I hope this simple project may help you Android Floating Widget

How do I remove the shadow border around a JavaFX ContextMenu?

I've been working on a Button extending class that when left-clicked on displays a stay-open popup menu (ContextMenu object) on a configurable side/corner of the button. The constructor takes an enumerated value like NORTH_LEFT that indicates the side of the button where it gets shown and which edges on both the button and popup are aligned. In other words the 2 should always show in an L shape combo, not a T shape.
So when I want to do something like EAST_BOTTOM where the bottom edges of both button and popup should align, I figured something like this would work:
PopupMenu.show(this, Side.RIGHT, 0, this.getHeight() - PopupMenu.getHeight());
But what I get is a Popup that appears much higher up then it should. That's because the PopupMenu.getHeight() call is returning a larger value then expected. I suspect because it is including the large shadow border in its dimensions. I've noticed that this semi-visible border also extends over my button a bit and prevents mouse clicks from registering on the edge of the button near the menu. So I have multiple reasons to want a border of 0 width.
I assume there is a way to do it via CSS. I've tried setting -fx-background-insets and -fx-padding to 0 but neither seems to make a difference. Any other suggestions?
The solution is to add -fx-effect: null; to your CSS for the ContextMenu. This removes the dropshadow effect that is the modena.css default for ContextMenus. Once I did that I was able to correctly place my menu wherever I needed it to go.
Credit for this working answer goes to José Pereda - we worked it out in the comments above.

Image Click event in Java LibGdx

I am working on a Street Fighter Game. I need to have a character selection screen for the user. How can I do this character selection in Java libGDX? This is my image code. Can I do this using ImageClick event?
splashTexture1 = new Texture(Gdx.files.internal("assets/gui/Character1.PNG"));
splashTexture1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
splashSprite1 = new Sprite(splashTexture1);
splashSprite1.setX(100);
splashSprite1.setY(180);
My suggestiong is using scene2d for menu or HUD stuff.
Check this out : https://github.com/libgdx/libgdx/wiki/Scene2d
scene2d is a 2D scene graph for building applications and UIs using a hierarchy of actors:
buttons
labels
sliders
text buttons
scrollable views (lists)
tables
your custom widgets
group of actors
You can add ClickListener to an actor. (In your case the actor is a Button)
You can do it in two ways. I'd recommend using both.
Common stuff
You can list images of all characters in a screen. And let the user select any one using one of the following.
Click event
Each image will have a separate ClickListener (If you have problem regarding that, you should search 'How to add clicklisteners to libgdx actors).
On clicking any image, the variable storing selected character (for the rest of the game) will be set with the image that has been clicked. And the screen is changed.
Keyboard event
One of the image will have focus drawn around it. The user can move focus around to other character images using arrow keys. When user presses enter, the character that currently has focus gets selected and the screen is changed.
Hope this helps.
I would recomend to use the Table-Layout from libgdx for it. Add an ImageButton to a Table and add an ClickListener to the ImageButton. Add the same Texture as up and down Texture and you are done. Maybe change it later so the user see that he has clicked a figure.
The Table gives you the ability to arrange those Buttons in the way you like and it's structured. Moreover it is easy to create a dynamic view, that does have new ImageButton for every new Texture you add to a folder for example. Just create a ScrollPane with a the Table of "figures" (which are the ImageButton with an listener) and you can add a bunch of it and let the user scroll down and up to check which he likes.

Having activity greyed out and having two buttons to select

Is there any way I can make two buttons appear up and have the main UI greyed out without calling the pause method in android? sort of like robo defender. thanks!
I'm unfamiliar with Robo Defender, but a common way to do this sort of this is with an overlay. You can put a view over your activity with an opacity of ~30%. This view can have a grey image that cover everything but your buttons.

Categories