Transparent png image not showing as transparent in Xamarin Absolute Layout - forms

Transparent png image not showing as transparent in Xamarin Absolute Layout
<AbsoluteLayout BackgroundColor="Aqua">
<Image Source="#drawable/icon.png" AbsoluteLayout.LayoutBounds="0.5,0.5,30,30"
AbsoluteLayout.LayoutFlags="PositionProportional" />
</AbsoluteLayout>

Just change your background color to transparent in your <Image>.
Something like that.
<Image Source="#drawable/icon.png" BackgroundColor="Transparent" AbsoluteLayout.LayoutBounds="0.5,0.5,30,30"
AbsoluteLayout.LayoutFlags="PositionProportional" />

Related

Creating a round border around user avatar in .NET MAUI

In my .NET MAUI app, I'm using the AvatarView in.NET MAUI Community Toolkit to create a nicely round user avatar which is pretty easy to do.
I now want to put a nice border around the image but I'm not getting the desired effect because when I set the BorderWidth property of the AvatarView, it places the border "inside" the image which makes the visible area smaller. I actually want to put the border "outside" the image so that I don't lose anything from the visible area. Here's an image that demonstrates this:
BTW, I tried setting the HeightRequest and WidthRequst larger and then setting the BorderWidth but it still seems to make the visible area smaller because all that's doing is that it makes the main image larger and with the border set, the visible area still doesn't show the additional data/area.
Here's my current code which places the border within the image -- which I can safely assume is the standard behavior.
<mct:AvatarView
ImageSource="{Binding UserInfo.AvatarUrl}"
BorderColor="{StaticResource UILightGray}"
BorderWidth="10"
CornerRadius="70"
HeightRequest="140"
WidthRequest="140"/>
How do I achieve the effect that I want? Basically, I'd like the border to go outside of the image, effectively adding some 10 pixels to the size of the image.
Alternatively, I don't mind placing the border within the image but I need a way to make the actual image 10 pixel smaller so that the visible area stays the same.
How can I achieve this by using or not using .NET MAUI Community Toolkit?
If you don't want to use the community toolkit package, then wrap the image with a Frame would be a trade-off for this scenario. And also you need to set the Aspect of the image to AspectFit.
<Frame HeightRequest="140"
WidthRequest="140"
CornerRadius="70"
HorizontalOptions="Center"
IsClippedToBounds="True"
Padding="0"
BorderColor="Gray"
Margin="0,0,0,0">
<Image
Aspect="AspectFit"
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="140"
WidthRequest="140"
VerticalOptions="Center"
HorizontalOptions="Center" />
</Frame>
Update:
You can also wrap a Border as Steve suggested.
<Border HeightRequest="160"
WidthRequest="160"
StrokeShape="RoundRectangle 80,80,80,80"
HorizontalOptions="Center"
StrokeThickness="8"
Margin="0,0,0,0">
<Image
Aspect="AspectFit"
Source="dotnet_bot.png"
SemanticProperties.Description="Cute dot net bot waving hi to you!"
HeightRequest="160"
WidthRequest="160"
VerticalOptions="Center"
HorizontalOptions="Center" />
</Border>

Binding from Firebasedatabase to Image in CollectionView depending on Dark or Light theme

I am Binding a Image in a CollectionView from a FirebaseDatabase with some Labels.
In the FirebaseDatabase i change the Image in Pic or when i use Binding to Picdark in the Picdark.
The images are in the folder Images , that works fine. Change the name in the Database and an other image is showing in the CollectionView.
This one i want to use for the Light Theme.
<Image
BackgroundColor="Transparent"
Grid.Column="1"
Aspect="AspectFill"
HeightRequest="60"
Source="{Binding Pic}"
WidthRequest="60" />
And this for the Dark Theme.
<Image
BackgroundColor="Transparent"
Grid.Column="1"
Aspect="AspectFill"
HeightRequest="60"
Source="{Binding Picdark}"
WidthRequest="60" />
</Border>
Now the question , what do i change to make the Binding Pic for Light and Picdark for Dark Theme.
This is what i tryed but nothing is showing.
<Image
Grid.Column="1"
Aspect="AspectFill"
BackgroundColor="Transparent"
HeightRequest="60"
Source="{AppThemeBinding Light={Binding Pic},
Dark={Binding Picdark}}"
WidthRequest="60" />
AppThemeBinding isn't a BindableObject, AppThemeBinding.Light isn't a BindableProperty, so you cannot use DynamicResource or Binding with it.
But you can change different images with special images in folder Resources/Images depending on the app theme.
Please refer to the following code:
<Image
Aspect="AspectFill"
BackgroundColor="Transparent"
HeightRequest="80"
WidthRequest="80"
Source="{AppThemeBinding Light= test1.png,
Dark= test2.png}"
/>

Xaml Xamarin Forms Absolute Layout Overlap

Given the above image, how would I go about to setup my Absolute Layouts?
I would like to have my blue absolute layout overlap the red border absolute layout. I understand there's a doc explaining how AbsoluteLayouts work however I still don't completely understand it 100%.
I have tried setting up the layouts the following way but the blue square is always hidden.
With the below code I don't end up seeing the blue layout at all.
<AbsoluteLayout>
<AbsoluteLayout x:Name="BlueSquare">
<StackLayout> (Asumme there is a list of things in here) </StackLayout>
</AbsoluteLayout>
<AbsoluteLayout x:Name="RedBorderArea">
<StackLayout> (Asumme there is another list of stuff in here) </StackLayout>
</AbsoluteLayout>
</AbsoluteLayout>
After tinkering around I needed to add the Blue square layout last and i removed the RedSquares parent layout.
<AbsoluteLayout>
<StackLayout x:Name="RedBorderArea" AbsoluteLayout.LayoutFlags="All" AbsoluteLayout.LayoutBounds="0.5,0.5,1,1"> (Asumme there is another list of stuff in here) </StackLayout>
<AbsoluteLayout x:Name="BlueSquare" LayoutFlags="PositionProportional, WidthProportional" LayoutBounds="1,0,1,1">
<StackLayout> (Asumme there is a list of things in here) </StackLayout>
</AbsoluteLayout>
</AbsoluteLayout>

UI5 Tiles to top of page

I'm new to UI5 and try to display some Tiles on a page.
However, they appear in the center of the screen, and I would like to have it at the top.
Below it is a graph that now doesnt even appear on the page without scrolling.
How do get it to the top of the page and remove the bottom margins ?
View:
<TileContainer
id="container"
tiles="{deviceData>/d/results}">
<StandardTile
number="BBB"
numberUnit="CCC"
title="ZZZ"
info="XXX"
infoState="CCC" />
</TileContainer>
<l:C3Chart id="chart1" class="c3Chart" height="300px" width="100%" columns="{cols}" type="{timeseries}" />
</Page> </mvc:View>
Set the height of your tile container to 50% ( or whatever suits your requirements).
code:
<TileContainer tiles='{/}' height='50%'>
<tiles>
<StandardTile title='{title}'>
</StandardTile>
</tiles>
</TileContainer>
You likely dont need a TileContainer here (tile container is full screen component to use when you have an unknown -but important- number of tiles).
You should use a simpler container like an HBox here
<HBox
id="container"
items="{deviceData>/d/results}">
<StandardTile
number="BBB"
numberUnit="CCC"
title="ZZZ"
info="XXX"
infoState="CCC" />
</HBox>

GWT Uibinder Image showing but not resizing

This image is showing but I can't resize it not matter the width or height values I use. Any thougt? Thankyou.
<ui:with field='res' type='com.hellomvp.client.resources.MyResources'/>
<ui:style>
.fortaImage { width:'50px'; height:'50px';}
</ui:style>
<g:DockLayoutPanel unit='EM'>
<g:north size="10">
<g:FlowPanel>
<g:Image styleName='{style.fortaImage}' resource='{res.fortaLogo}'/>
<g:InlineLabel>FortaService</g:InlineLabel>
<g:ListBox></g:ListBox>
<g:InlineLabel>DateIn</g:InlineLabel>
<d:DateBox></d:DateBox>
<g:InlineLabel>DateOut</g:InlineLabel>
<d:DateBox></d:DateBox>
<g:Button>Cerca</g:Button>
</g:FlowPanel>
</g:north>
</g:DockLayoutPanel>
When you use <g:Image resource="..."/>, GWT uses a background image. Background images cannot be resized in CSS 2.1. (I really wish it was possible!)
All you can do is either have a 50x50px version of the image on the server, or use <g:Image url="..."/> instead. This creates a normal <img src="..."/> instead of the background image, but you can't specify a ClientBundle resource here.
addStyleNames="{style.fortaImage}"
not
styleName='{style.fortaImage}'