2017-08-23 12 views
2

Xamarinでカスタムレンダリングを使用してラジオボタンを実装しました。ラジオボタンは左に揃えられ、テキストはデフォルトで右に揃えられます。ラジオボタンの位置を変更するにはどうすればよいですか?Xamarinでラジオボタンの位置を変更する方法は?

XAMLコードは、レンダリング

<StackLayout HorizontalOptions="Start" VerticalOptions="CenterAndExpand"> 
      <control:BindableRadioGroup x:Name="SortPicker" 
              TextColor="Gray" 
              CheckedChanged="OnCheckedChanged" 
              Padding="50,0,0,10" 
              WidthRequest="1100" 
              Spacing="20"> 

      </control:BindableRadioGroup> 
      </StackLayout> 

以下のコードです:

<application android:label="app label" android:supportsRtl="true"/> 

などのようなコントロールのLayoutDirectionPropertyを設定:

protected override void OnElementChanged(ElementChangedEventArgs<CustomRadioButton> e) 
     { 
      base.OnElementChanged(e); 

      if (Control == null) 
      { 
       var radButton = new RadioButton(Context); 
       colorStateList = radButton.TextColors; 
       radButton.CheckedChange += this.RadButtonCheckedChange; 

       SetNativeControl(radButton); 
      } 

      Control?.SetPadding(30, Control.PaddingTop, 0, Control.PaddingBottom); 
      Control.Text = e.NewElement.Text; 
      Control.Checked = e.NewElement.Checked; 
      UpdateTextColor(); 

      if (e.NewElement.FontSize > 0) 
      { 
       Control.TextSize = (float)e.NewElement.FontSize; 
      } 

      if (!string.IsNullOrEmpty(e.NewElement.FontName)) 
      { 
       Control.Typeface = TrySetFont(e.NewElement.FontName); 
      } 
     } 
+2

XAMLコード/レンダラーコード –

+0

を表示できますか?@Jorydy:コードサンプルを追加しました。 – Melody

答えて

0

アプリケーションマニフェストでtrueにsupportsRtlプロパティを有効にしてください:

Control.LayoutDirection = LayoutDirection.Rtl; 
関連する問題