Xamarin forms custom renderer issue for Android

We have an issue and need your assistance.

We have developed Xamarin forms custom renderer grid view with Absolute Layout. It is working fine in iOS (Image 1 attached); however, in Android it is not working (Image 2 attached). In Android, we are able to achieve the background color with Absolute Layout. But, we can’t display images, label, and button control.
Kindly help us out in this regard.

Below is code for the reference :

<?xml version="1.0" encoding="UTF-8"?> <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:controls="clr-namespace:ImageGallery.Forms.Controls;assembly=ImageGallery" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="ImageGallery.Views.GridViewPage" Title="GridView" Padding="0,20,0,0"> <ContentPage.ToolbarItems> <ToolbarItem Name="" x:Name="tbCancel" Activated="OnClickCancel" /> <ToolbarItem Name="Select" x:Name="tbSelect" Activated="OnClickSelect" /> </ContentPage.ToolbarItems> <ContentPage.Content> <controls:GridView x:Name="GrdView" RowSpacing="5" Padding="20" ColumnSpacing="5" ItemWidth="200" ItemHeight="200" ItemsSource="{Binding Images}" HeightRequest="400"> <controls:GridView.ItemTemplate> <DataTemplate> <ViewCell> <ViewCell.View> <AbsoluteLayout BackgroundColor="Green"> <Image Source="{Binding ImageNamePath}" AbsoluteLayout.LayoutBounds="1.0, 1.5, 1.0, 1.0" AbsoluteLayout.LayoutFlags="All" /> <Label Text="{Binding ImageName}" TextColor="Black" BackgroundColor="White" AbsoluteLayout.LayoutBounds="0.3, 1.5, 1.0, 0.4" AbsoluteLayout.LayoutFlags="All" /> <Button Image="images.png" x:Name="btnLike" AbsoluteLayout.LayoutBounds="1.4, 1.1, 0.5, 0.2" AbsoluteLayout.LayoutFlags="All" /> </AbsoluteLayout> </ViewCell.View> </ViewCell> </DataTemplate> </controls:GridView.ItemTemplate> </controls:GridView> </ContentPage.Content> </ContentPage>

Posts

  • JayParikhJayParikh USUniversity ✭✭
    edited September 2015

    .

  • You should try Grid control instead of Absolute Layout. Try to design your cell using Grid control by setting related row column number, may be your issue get resolved

  • You should try Grid control instead of Absolute Layout. Try to design your cell using Grid control by setting related row column number, may be your issue get resolved.

  • You should try Grid control instead of Absolute Layout. Try to design your cell using Grid control by setting related row column number.

Sign In or Register to comment.