Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

How to get Absolute Layout and Relative Layout to Autosize to the size of their child element

$
0
0

The design requirement is to put a label and a button on the image. The Image is in a DataTemplate of ListView. I want to use Absolute Layout. But it expand way out of the child element (image). So how to make the absolute layout the same size of the image. On the other hand if I use relative layout it also expands out of the child element. But it takes less space than absolute layout. I know Absolute Layout and RelativeLayout are the best for this scenario. But they were leaving lots of empty space between list view items. Please help me out and explain how to use both of these layouts appropriately in order to size them according to their child elements. The code is as follows


<ListView.ItemTemplate>

                     <AbsoluteLayout >

                        <Image Source="BuyersCard.png" > </Image>

                       <Label Text="{Binding Name}" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".1,.2"></Label>

                            <Button Text="Contact" BorderColor="Red" AbsoluteLayout.LayoutFlags="PositionProportional" AbsoluteLayout.LayoutBounds=".7,.2"></Button>

                    </AbsoluteLayout>
                  </ViewCell>       
            </DataTemplate>
        </ListView.ItemTemplate>

    </ListView>

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>