如何在单选按钮到xamarin表单中的文本之间设置空格

时间:2017-11-13 05:34:01

标签: xamarin xamarin.forms xamarin.android

我的单选按钮的自定义渲染器是,

public class RadioButtonRenderer:ViewRenderer     {

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


        if (e.OldElement != null)
        {
            e.OldElement.PropertyChanged += ElementOnPropertyChanged;                                
        }

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

            this.SetNativeControl(radButton);
        }

        Control.Text = e.NewElement.Text;
        Control.Checked = e.NewElement.Checked;

        Element.PropertyChanged += ElementOnPropertyChanged;
    }        

任何人都可以知道如何在单选按钮和文本之间设置空格。

1 个答案:

答案 0 :(得分:4)

Android RadioButton widget is a CompoundButton and you can set its TextView's relative padding:

enter image description here

Control.SetPaddingRelative(150, 0, 0, 0);

enter image description here