I'm trying to put a label inside of my image, I couldn't use a Margin
property, because some reason it's not working, untill now I have this :
And what I want is this :
XAML :
<StackLayout Orientation="Vertical">
<Label HorizontalOptions="Center" Text="something" TextColor="Black"/>
<Image HorizontalOptions="Center" Source="spin.png"/>
</StackLayout>
You need a Grid
instead of a StackLayout
(notice how both the Label
and the Image
are in the same row and column):
<Grid HorizontalOptions="Center"
VerticalOptions="Center">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Image HorizontalOptions="Center"
Source="spin.png"
Grid.Row="0"
Grid.Column="0"/>
<Label HorizontalOptions="Center"
Text="something"
TextColor="Black"
Grid.Row="0"
Grid.Column="0"/>
</Grid>
Because the Label
is listed beneath the Image
in the XAML code above, the Label
will be drawn on top of the Image
.
You also could have used an AbsoluteLayout
, which is another layout that is good at layering things.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.