android - RelativeLayout in StackLayout Width Calculation -


i've got odd problem relativelayouts nested in stacklayout, appears stacklayout calculates width of elements should using relativelayout width , relativelayout recalculates again afterwards. results in child control being relative width squared, following controls being placed @ relative width.

is bug or doing wrong?

example

<?xml version="1.0" encoding="utf-8" ?> <contentpage x:class="myclass"              xmlns="http://xamarin.com/schemas/2014/forms"              xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"              >    <stacklayout orientation="horizontal" backgroundcolor="blue">     <relativelayout>       <contentview backgroundcolor="red"            relativelayout.xconstraint=                 "{constraintexpression type=relativetoparent,                                       property=width,                                       factor=0}"           relativelayout.widthconstraint=                 "{constraintexpression type=relativetoparent,                                       property=width,                                       factor=0.707106}"           relativelayout.yconstraint=                   "{constraintexpression type=relativetoparent,                                         property=height,                                         factor=0}"           relativelayout.heightconstraint=                 "{constraintexpression type=relativetoparent,                                       property=height,                                       factor=1}">        </contentview>      </relativelayout>     <relativelayout>       <contentview backgroundcolor="green"            relativelayout.xconstraint=                 "{constraintexpression type=relativetoparent,                                       property=width,                                       factor=0}"           relativelayout.widthconstraint=                 "{constraintexpression type=relativetoparent,                                       property=width,                                       factor=0.5}"           relativelayout.yconstraint=                   "{constraintexpression type=relativetoparent,                                         property=height,                                         factor=0}"           relativelayout.heightconstraint=                 "{constraintexpression type=relativetoparent,                                       property=height,                                       factor=1}">        </contentview>      </relativelayout>    </stacklayout> </contentpage> 

screen shot

the 2 relativelayout elements confusing factor, , fact each specified @ x position 0 relative parent stacklayout, seems conflict.

it seems comments if each relativelayout expected half width of parent stacklayout, layout simplified eliminating 1 of relativelayout elements.

the specified widths of child strips divided 2 width of each intended relative parent stacklayout, , x positions set relative parent position them horizontally.

here came with:

<?xml version="1.0" encoding="utf-8" ?> <contentpage x:class="app1.homepage"          xmlns="http://xamarin.com/schemas/2014/forms"          xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" >  <stacklayout orientation="horizontal" backgroundcolor="blue">   <relativelayout>     <contentview backgroundcolor="red"         relativelayout.xconstraint=           "{constraintexpression type=relativetoparent,                                  property=width,                                  factor=0}"         relativelayout.widthconstraint=           "{constraintexpression type=relativetoparent,                                  property=width,                                  factor=0.35}"         relativelayout.yconstraint=           "{constraintexpression type=relativetoparent,                                  property=height,                                  factor=0}"         relativelayout.heightconstraint=           "{constraintexpression type=relativetoparent,                                  property=height,                                  factor=1}">     </contentview> <!-- </relativelayout> <relativelayout> -->     <contentview backgroundcolor="green"         relativelayout.xconstraint=           "{constraintexpression type=relativetoparent,                                  property=width,                                  factor=0.5}"         relativelayout.widthconstraint=           "{constraintexpression type=relativetoparent,                                  property=width,                                  factor=0.25}"         relativelayout.yconstraint=           "{constraintexpression type=relativetoparent,                                  property=height,                                  factor=0}"         relativelayout.heightconstraint=           "{constraintexpression type=relativetoparent,                                  property=height,                                  factor=1}">       </contentview>     </relativelayout>   </stacklayout> </contentpage> 

does produce closer expected?

screenshot


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -