locked
Demo banner RRS feed

  • Question

  • User148945 posted

    Hi!

    Does anyone know how to implement custom renderer for Page/ContentPage in Android and iOS to display Demo banner eg. in the top right corner?

    I've tried to override OnElementChanged(where element is ContentPage) and OnDraw(with Canvas) methods in Android project. I can successfully change every page's title, background etc. but I don't know how to place Demo banner at specific coordinates.

    I attached an example image of how it should look.

    Thanks!

    Thursday, March 31, 2016 7:49 AM

Answers

  • User179286 posted

    No, all LayoutClasses derive from VisualElement and therefore have a BackgroundColor property. It helps a lot to set this to a contrasting color if you want to see where your Layout is positioned.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, April 1, 2016 8:25 AM

All replies

  • User179286 posted

    Why not just using an AbsoluteLayout or ReleativeLayout as outmost Layout of the Page and postion the Banner with that on top of all other Elements?

    Thursday, March 31, 2016 1:21 PM
  • User148945 posted

    @ThomasBurkhart I need this Demo banner to be on every page, and currently in my project there are about 40 pages.

    So, that wouldn't be efficient and modular solution.

    Thursday, March 31, 2016 1:41 PM
  • User179286 posted

    I see your problem. Couldn't you create a BasePage Class an inherit all other pages from it?

    Thursday, March 31, 2016 1:46 PM
  • User148945 posted

    I already have MyContentPage class which inherit from default ContentPage.

    So, I want to add Demo banner in my MyContentPage.

    It would be better to implement this fully in PCL project, but I'm not sure if this is possible.

    My idea was to create MyContentPage custom renderer, which will draw Demo banner and place it as top layer for all pages.

    Thursday, March 31, 2016 2:00 PM
  • User179286 posted

    Still thinking Adding an Absolute Layout to MyContentPage would be the cleanest way.

    Thursday, March 31, 2016 2:07 PM
  • User148945 posted

    Tried that, but every page content overrides my AbsoluteLayout or send it back (I'm not sure because I can't see my AbsoluteLayout).

    Thursday, March 31, 2016 2:15 PM
  • User179286 posted

    Tipp set the BackgroundColor of the LayOut. Are you using Xaml or Code?

    Thursday, March 31, 2016 2:40 PM
  • User148945 posted

    I'm using Xaml. What do you mean by set the BackgroundColor? On MyContentPage?

    Friday, April 1, 2016 6:55 AM
  • User179286 posted

    No, all LayoutClasses derive from VisualElement and therefore have a BackgroundColor property. It helps a lot to set this to a contrasting color if you want to see where your Layout is positioned.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Friday, April 1, 2016 8:25 AM