Sub 10 height request layouts/views not allowed - xamarin

I'm trying to add line dividers between views. However, there is a forced margin on every element I try (Image, BoxView, Frame, Label). I set the margin to be 0, the HeightRequest is always 3, but as you can see the view bounds expand past the actual view. Is there a specific view I'm supposed to be using? I just want the gray line and nothing more.
var line2 = new Frame
{
WidthRequest = (App.ScreenDpWidth / 2),
MinimumHeightRequest = 3,
HeightRequest = 3,
BackgroundColor = Color.FromHex("#229EBB"),
Margin = new Thickness(0, 0)
};

I assume you are layouting your elements either in a Grid or a StackLayout.
By default, the StackLayout.Spacing, Grid.RowSpacing and Grid.ColumnSpacing properties are set to 6d.
Without more information, I think that's what you're seeing in your code. Change those values to 0d.
Also, if you only want a gray line, you can use a BoxView which will draw a gray box, and set it's Height to 1d.

Related

Moviepy - Place textclips at relative position

How do I place a textclip, right below the other? I require to place an image at the left of the video and two lines of text to the right of image, that are placed one below the other.
Something like this:
I tried to use set_position, but doesn't scale well for different videos (of different resolutions). By adjusting the arguments of set_position, I am able to place the textclips one below the other without gap in one resolution, but when I go to a higher resolution video, it shows a gap (I understand why the gap comes, but not sure how to prevent it)
txt_clip1 = TextClip("This is line 1 of text", fontsize = 12, color = 'white', bg_color='black')
txt_clip1 = txt_clip1.set_duration(7).set_start(0).set_end(7)
txt_clip1 = txt_clip1.set_position((0.1,0.90), relative=True).set_opacity(0.6)
txt_clip2 = TextClip("This is line 2 of the text, smaller font", fontsize = 8, color = 'white', bg_color='black')
txt_clip2 = txt_clip2.set_duration(7).set_start(0).set_end(7)
txt_clip2 = txt_clip2.set_position((0.1,0.93), relative=True).set_opacity(0.6)
I tried to insert a new line character in the text, but that doesn't suit me because the second line of text has different font properties.
Hopefully this will help you
txt_clip1 = TextClip(
"Cool effect 2nd line", color="black", bg_color="red", font="Amiri-Bold", kerning=5, fontsize=20
)
cvc = CompositeVideoClip([txt_clip1.set_position("East")], size=screensize)
txt_clip1 = txt_clip1.set_position((5,35))
.set_position mother take to arguments 1st is the position from the left screen and second is the position from the top
so your code is like something
txt_clip1 = txt_clip1.set_position((5,500))
txt_clip2 = txt_clip2.set_position((5,535))
It will place the text in the position you want.
Hopefully, this will help.
Happy coding

Strange behavior with Grid definition auto height and stacklayout inside the row

I am using a grid with autoheight for row definition (I have a Editor inside, so my row can update it's height depending of the text).
My issue is, in another cell, there is a stack layout
StackLayout stackEspeceVariete = new StackLayout()
{
Children = { autoCompleteEspece, autoCompleteVariete }
};
stackEspeceVariete.Orientation = StackOrientation.Horizontal;
gridLignes.Children.Add(stackEspeceVariete);
Grid.SetRow(stackEspeceVariete, gridLignes.RowDefinitions.Count - 1);
Grid.SetColumn(stackEspeceVariete, 2);
Adding the stacklayout cause my row to take all the screen size. I want the stacklayout to take the size it's needed, not all screen size.
I tried changing the vertical option but no success.
I also tried to fix the stacklayout height to 130, it's was "working" but, the row height was no longer changing, depending on the editor text.
It's like the row is fixed to the stacklayout child
Do you have any idea ?
Thanks

iText 7 - How to fill a canvas rectangle with a transparent color

In iText 7.1.9 I am taking a pdf created programmatically (not via iText) and need to apply a transparent rectangle along the left side and bottom to ensure the no content exists within a predefined clear zone (for print).
The below code places the yellow rectangles correctly but the desired result is the for the yellow fill to be semi-transparent or not 100% opaque so that visual inspection will show the content that that intersects with the rectangle instead of the rectangle clipping the content.
var page = pdf.GetPage(1);
PdfCanvas canvas = new PdfCanvas(page);
canvas.SaveState();
canvas.SetFillColor(iText.Kernel.Colors.ColorConstants.YELLOW);
var pageHeight = page.GetPageSize().GetHeight();
var pageWidth = page.GetPageSize().GetWidth();
// left side
canvas.Rectangle(0, 0, 15, pageHeight);
// bottom
canvas.Rectangle(0, 0, pageWidth, 15);
canvas.Fill();
canvas.RestoreState();
I attempted to use a TransparentColor but canvas.SetFillColor won't accept a TransparentColor, are there any other options?
When we speak about low-level content stream instructions, color itself and transparency levels are specified separately in PDF syntax. The TransparentColor class that you speak about was designed to simplify lives of users who are less familiar with nuances of PDF syntax, but it it a higher-level class that you can use e.g. in layout module, and in your case you operate with the document on quite low level.
Long story short, to set color transparency you only need one additional line next to setting the color itself:
canvas.SetExtGState(new PdfExtGState().SetFillOpacity(0.5f));
So the code becomes:
var page = pdf.GetPage(1);
PdfCanvas canvas = new PdfCanvas(page);
canvas.SaveState();
canvas.SetFillColor(iText.Kernel.Colors.ColorConstants.YELLOW);
canvas.SetExtGState(new PdfExtGState().SetFillOpacity(0.5f));
var pageHeight = page.GetPageSize().GetHeight();
var pageWidth = page.GetPageSize().GetWidth();
// left side
canvas.Rectangle(0, 0, 15, pageHeight);
// bottom
canvas.Rectangle(0, 0, pageWidth, 15);
canvas.Fill();
canvas.RestoreState();

Xamarin Forms Stacklayout StackOrientation.Horizontal

When i set StackOrientation.Horizontal for stacklayout and setting 5 labels it displays properly.
But when the number of labels count is increased labels text size reduced and all labels are aligned for available width.
How to display full text for all labels also move label to next line if the labels count exceeds?
Use WrapLayout instead:
var layout = new WrapLayout {
Orientation = StackOrientation.Horizontal,
HorizontalOptions = LayoutOptions.Fill,
Padding = new Thickness (0, padding, 0, padding)
};
layout.Children.Add (item);
Result:
StackLayout with Horizontal orientation will only use "one line".
For that case you should use a GridLayout or WrapLayout (From Xlabs).
In alternative you could use a StackLayout with Horizontal orientation and each Child is a StackLayout with Vertical orientation.
Xamarin 3.0 introduced FlexLayout for exactly this use-case. It's based on CSS Flexboxes.

BlackBerry - Resize the width of horizontal manager

Is it possible to resize the width of horizontal manager. I want to create two buttons in horizontal manag, set the background border. I am using the following code for that. It is working fine. But as there are only two buttons and doesn't occupy the entire screen of 320 width, setting border is happening only for those two buttons background. So i could see the white space apart from the horizontal width in forward and backward spaces. So i want to create a Horizontal manager itself with 320 width, so that setting border color will show for the entire width. Is it possible to resize the width of horizontal manager?
XYEdges borderColor = new XYEdges(Color.BLACK, Color.BLACK, Color.BLACK, Color.BLACK);
XYEdges noPadding = new XYEdges(2, 2, 2, 2);
HorizontalFieldManager hzBtnFldManager = new HorizontalFieldManager(HorizontalFieldManager.FIELD_HCENTER);
createButton = new CustomControl("Create", ButtonField.FOCUSABLE | ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER, 83, 15);
cancelButton = new CustomControl("Cancel", ButtonField.FOCUSABLE | ButtonField.CONSUME_CLICK | ButtonField.FIELD_HCENTER, 83, 15);
hzBtnFldManager.add(createButton);
hzBtnFldManager.add(cancelButton);
Border btnBarPaddingBorder = BorderFactory.createSimpleBorder(noPadding, borderColor, Border.STYLE_SOLID);
hzBtnFldManager.setBorder(btnBarPaddingBorder);
hzBtnFldManager.setBackground(BackgroundFactory.createSolidBackground(Color.GRAY));
this.setStatus(hzBtnFldManager);
Maybe try using the Field.USE_ALL_WIDTH style on the HorizontalFieldManager?

Resources