question

Oulcanzen-2845 avatar image
0 Votes"
Oulcanzen-2845 asked JarvanZhang-MSFT commented

How can i put a frame and button side by side and adjoining?

I want to put a frame and a button side by side and adjoining but when i do that, there is always a space between them and i can't remove it. Here is the code i wrote:


 <StackLayout Margin="0,740,0,0" Orientation="Horizontal"  >
                     <Frame BackgroundColor="#BD3AB8" HeightRequest="20" WidthRequest="380">
                         <Label Text="TOPLAM: 50 TL" TextColor="White" FontSize="17" />
    
    
                     </Frame>
                        
                     <Button Text="SİPARİŞİ ONAYLA" TextColor="White" WidthRequest="160" FontSize="17" BackgroundColor="Purple" Padding="0"/>
    
                 </StackLayout>

and the result looks like this:

![97806-image.png][1]

i want to remove that space that showed with arrow. How can i solve this problem?


dotnet-xamarin
image.png (8.7 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

alessandrocaliaro avatar image
0 Votes"
alessandrocaliaro answered

StackLayout has a "Spacing" property

xamarin.forms.stacklayout.spacing

you can try to set it to 0, then set "margin" to 0 from Frame and Button

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

JarvanZhang-MSFT avatar image
0 Votes"
JarvanZhang-MSFT answered JarvanZhang-MSFT commented

Hello,​

Welcome to our Microsoft Q&A platform!

For this function, try setting the Spacing property of the layout to 0. The Spacing property indicates the amount of space between each child element. It seems you set the value of margin top to '740'. Do you want to place the stackLayout at the bottom of the page? If so, just set the VerticalOptions to End or EndAndExpand.

Check the code:

<StackLayout VerticalOptions="End" Orientation="Horizontal" Spacing="0">
    <Frame BackgroundColor="#BD3AB8" HeightRequest="20" WidthRequest="380" IsClippedToBounds="True">
        <Label Text="TOPLAM: 50 TL" TextColor="White" FontSize="17" Padding="0"/>
    </Frame>

    <Button Text="SİPARİŞİ ONAYLA" TextColor="White" WidthRequest="160" FontSize="17" BackgroundColor="Purple"/>
</StackLayout>


Best Regards,

Jarvan Zhang


If the response is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Oulcanzen-2845 May I know whether your issue has been solved or not? If not, please share it in here. We can work together to figure it out.

0 Votes 0 ·