I am trying to create a layout as show in the image attached here:
Here are my screen components,
Screen title field
Button at the center of screen
HorizontalFieldManager containing 3 buttons docked to bottom of screen
Add banner, placed as docked below.
I have completed all of the 1, 2 and 4. I have used setStatus(Field) to place the ad banner. Also, I have customized the HorizontalFieldManager for holding 3 fields justified aligned. Now I don't know how could I place it to the bottom of screen just above the add banner, as I've already used setStatus() for the ad banner. Also, if the virtual keyboard comes up, I want it to cover up the bottom of the screen, rather than push the HorizonalFieldManager and ad banner up.
Dont use setstatus for adding banner stuff instead you can use two horizontal managers at bottom of screen considering Display.getHeight().
I ve done similar kind of screen in my application here is the brief info regarding that.
1) parent Manager (either Vertical/Horizontal) say parentManager
2) Two Horozontal managers with appropriate height and Maximum width (override in sublayout of horizontal managers) and add both these two a verticalfield manager(bottommanager)
3) then here comes tricky part. To the parent Manger override sublayout and add these steps
vfm_screen = new VerticalFieldManager(ScrollView.NO_VERTICAL_SCROLL | HORIZONTAL_SCROLL
| NO_VERTICAL_SCROLL){
protected void sublayout(int maxWidth, int maxHeight) {
setPositionChild(parentManager, 0, 0);
layoutChild(parentManager, Display.getWidth(), Display.getHeight());
setPositionChild(bottommanager, 0, Display.getHeight()-114);
layoutChild(bottommanager, Display.getWidth(), 114);
setExtent(Display.getWidth(), Display.getHeight());
};
};
vfm_screen.add(parentManager);
vfm_screen.add(bottommanager);
add(vfm_screen);
Here 114 is hard sized and you can change it based on your requirement. and adding Button to that parent manger at center of screen.
Combine the ad-banner and the 3 justified fields with a VerticalFieldManager, then pass the combined manager to setStatus().
Related
I am working on layout for iPhoneX and have an issue with action sheets and Safari browser. This is an extra space. I need that my action sheets display more at the bottom ? How can I do that? I guess I need to disable safe area but how can I do it?
The reason why it happens probably that I use 2 UIWindows: one for all content and the second to display banner at the bottom of the screen.
the space that is outlined - is something to hide my app from everyone :) It does not exist in the app!
I want the action sheet be closer to the bottom. It works well on all devices except iPhoneX. I have 2 UIWindows (one for all content and the second one for ad at the bottom). So, for iPhoneX the content window has probably some safe area inset and becaise of that action sheet shows not from the bottom edge
You don't have to disable the Safe Areas for the View Controller. They are still useful for the top, trailing and leading edges.
To remove the grey bar all you need is to set the bottomAnchor or your containing view to your superView instead of the bottom safe area with a constant of what you need.
You can also further adjust safe area insets with additionalSafeAreaInsets. https://developer.apple.com/documentation/uikit/uiviewcontroller/2902284-additionalsafeareainsets That allows you to leave them as is for the edges that you don't want to modify.
In a regular app, in the initial viewController, if I add two UIHorizontalStackViews, and add two buttons to each, and set their heights to be 0.5 of the view, while setting the left, top, and right properties to 0, they behave as we expect:
However, if I do this exact same process on a custom keyboard extension that uses a viewController, I get this:
You would think that it would make each UIHorizontalStackViews take 50% of the keyboard height, but no the keyboard shrinks and the buttons get smaller.
I then tried adding one single vertical stackview, that had 4 rows of horizontalstackviews, making it have height of 1.0 of it's view, and margins of left 0, top 0, right 0, in this case, the window ended up taking far more than half of the screen, more than the custom keyboard's height is allowed to be.
Not sure if this is a bug or what. I was assuming autolayout would be adjusting the keyboard height depending on screen orientation, and phone model.
I wanna center my Label component in Horizontal Layout (I'm working on navigation bar) but I still want to have hamburger menu button aligned to the left side of the screen,
I tried to use
navbar.setComponentAlignment(myLabel, Alignment.MIDDLE_CENTER);
on my Horizontal Layout but this don't work, it only center in verticaly,
What can I do to achive that?
Vaadin Label is by default 100% wide, so you need to set its width to undefined to center it:
myLabel.setWidthUndefined();
Of course, your HorizontalLayout must be 100% wide (it's undefined by default).
I'm trying to create a HorizontalFieldManager in blackberry app, I want fields to be left aligned which is HFM's default layout but then I want to display one BitmapField right aligned, setMargin(0, 0, 0, Display.getWidth() - bitmap.getWidth()) works fine until I add other Fields in the manager, any ideas please
That's a bit hacky, normally the children are the ones who define the alignment inside the parent manager..
You create the hfm using all width available:
HorizontalFieldManager hfm = new HorizontalFieldManager(Field.USE_ALL_WIDTH);
Then you add the fields (or managers) aligned to left:
hfm.add(new LabelField("Left", Field.FIELD_LEFT));
And then you add the fields that must be aligned right. I'm using labels here, but every class extending Field (including managers) has a constructor accepting flags as argument:
hfm.add(new LabelField("Right", DrawStyle.RIGHT | Field.USE_ALL_WIDTH));
I have multiple ButtonFields in a VerticalFieldManager. By default the width of each button depends on the text it contains.
I would like all the buttons to be of the same width - equal to the width of the widest button.
Take a look at the BlackBerry Developers Knowledge Base:
How to - Implement advanced buttons, fields, and managers
Last Updated: 12 February 2010
Article Number: DB-00796
You are probably looking for the VerticalButtonFieldSet!
Step 1 - Extend the VerticalFieldManager class, and make the constructor take in a bunch of Strings that you want to put end each button.
Step 2 - Find the longest of String out of the Strings passed into the manager.
Step 3 - create the button for the longest string
Step 4 - create all other buttons, and set their width to the same as the 1st (see setExtent)
Step 5 - add the buttons to the manager in the order you want them to appear
FIN
Have you tried using the Field.USE_ALL_WIDTH style flag?
Try ButtonField buttonField = new ButtonField("ButtonText", Field.USE_ALL_WIDTH);
and that should use the full width.
If that doesn't work, try extending ButtonField, overriding layout and calling setExtent(width, height) with the width and height that you want.