2017-08-29 58 views
0

我與xamarin形式 工作,我需要創建兩個對象的佈局positionated這樣的:一半以上xamarin其它圖像的圖像形成

enter image description here

半一個(圓)以上另一個對象(方形)

我已經搜索,它似乎我需要使用相對佈局... 我試圖做到這兩個對象設置在同一個網格(行和第0行),然後,使用constraintX在同一個Y中用因子0和負常數設置第二個......但它沒有工作。不幸的是,刪除了這些行,並且無法在這裏顯示......唯一發生在此處的是:兩者在y中的位置相同,但我可以像上面的圖片那樣做... 某人可以幫助我有一個例子,想法或任何東西?非常感謝你!

我現在的代碼 - rodape圖像是正方形,重新加載是圓圈 我現在重新加載在廣場下的事實是錯誤的,但是,現在,它假裝視覺......它給我我想要的結果接近......但不完全

<!--Rodapé Grid--> 
<RelativeLayout HorizontalOptions="FillAndExpand" 
       VerticalOptions="EndAndExpand" 
       BackgroundColor="Black"> 
    <Grid BackgroundColor="Red" 
      RelativeLayout.WidthConstraint="{ConstraintExpression Type=RelativeToParent, 
                   Property=Width, 
                   Factor=1, 
                   Constant=0}"> 
     <Grid.RowDefinitions> 
      <RowDefinition Height="*"/> 
     </Grid.RowDefinitions> 

     <Image Source="rodape.png" 
       Aspect="Fill" 
       HorizontalOptions="FillAndExpand" 
       Grid.Row="0" 
       Grid.Column="0"> 
      <Image.GestureRecognizers> 
       <TapGestureRecognizer Tapped="FranqueadoOnTapGestureRecognizerTapped"/> 
      </Image.GestureRecognizers> 
     </Image> 
     <!--Escrito Rodapé--> 
     <StackLayout Orientation="Vertical" 
        VerticalOptions="End" 
        HorizontalOptions="FillAndExpand" 
        Grid.Row="0" 
        Spacing="0" 
        Grid.Column="0"> 
      <Image Source="reloadicon.png"/> 
      <StackLayout Orientation="Horizontal" 
         HorizontalOptions="Center"> 
       <local:MyLabel NamedFontSize="Medium" 
           FontSizeFactor="0.7" 
           Text="Seja um Franqueado:" 
           TextColor="White" 
           FontAttributes="Bold" 
           Style="{StaticResource labelsfont}"/> 
       <local:MyLabel NamedFontSize="Medium" 
           FontSizeFactor="0.7" Text="montanaexpress.com" 
           Style="{StaticResource labelsfont}" 
           TextColor="{StaticResource laranjacolor}"/>    
      </StackLayout> 
     </StackLayout> 
    </Grid> 
</RelativeLayout> 
+0

不是100%確定這裏要問的是,但如果你需要在一個正方形上畫一個圓,這是一個自定義控件的好選擇,你直接畫到本地畫布 – snowCrabs

回答

3

嘗試這樣的事情,我認爲這是簡單的:

<Grid> 
    <BoxView Grid.Column="0" Grid.Row="1" 
      Color="Red" 
      HeightRequest="20" 
      HorizontalOptions="FillAndExpand"/> 
    <Frame Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" 
      BackgroundColor="Yellow" 
      HorizontalOptions="CenterAndExpand" 
      VerticalOptions="CenterAndExpand" 
      WidthRequest="40" 
      HeightRequest="40" 
      CornerRadius="40" 
      Margin="0,5,0,10"/> 
</Grid> 

你會得到什麼: enter image description here

+0

但是,當我使用高度和寬度請求時,靜態大小,以我的看法,不是嗎? –

+0

是的,我用它來實現你的視覺模型。您必須將BoxView和Frame元素更改爲圖像。關於固定大小,並使用像Horizo​​ntal和VerticalOptions,Grid.Column,Row和RowSpan這樣的位置屬性。告訴我它是否可以像你想要的那樣工作 –