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

Oğulcan Özen 1 Reputation point
2021-05-19T12:30:33.54+00:00

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?

Developer technologies | .NET | Xamarin
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Alessandro Caliaro 4,196 Reputation points
    2021-05-19T12:58:34.687+00:00

    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

    0 comments No comments

  2. JarvanZhang 23,971 Reputation points
    2021-05-20T01:54:04.467+00:00

    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.