Dynamic UI in Xamarin.Forms

后端 未结 2 1190
一个人的身影
一个人的身影 2020-12-22 09:22

I would like to add a scrollable menu to a mobile app page.
Here Transfer, Accounts, Payment and Transaction are generated from an XML file.
The rest is static layout.

相关标签:
2条回答
  • 2020-12-22 10:07

    i think you can use "Collection View" which is new feature of xamarin.forms or "bindable layout" to make it dynamic.

    0 讨论(0)
  • 2020-12-22 10:25

    Dynamic UI creation is simple like the people said and there are many examples. But i think the problem is creating your own control according to your needs. For example i ended up with writing my own button with image in it like this:

    So you have to write a method that creates a vertical stack layout (lets say outer container),and add a horizontal container to that "outer container" (lets say inner container) than add an image and a label to this "inner container" and make "innerContainer.HorizontalOptions = LayoutOptions.Center" etc. If you want border it goes complicated :)

    Vertical Stack (whole container)
    ->Vertical Stack (height 2px) upper border
    ->Horizontal Stack (to hold middle controls,left border,inner image and text holder, right border etc.)
        ->Horizontal Stack (width 2 px) left border
        ->Vertical Stack (layoutOptions=Fillandexpand)
            ->Image (layoutOptions=Center)
            ->Label (layoutOptions=Center)
        ->Horizontal Stack (width 2 px) right border
    ->Vertical Stack (height 2px) lower border
    

    So you have to join the controls like this hierarcy. First think how can you draw your control with existing controls than code it :) Hope i made my self clear.

    0 讨论(0)
提交回复
热议问题