在选择Entry Control之前,Xamarin.Forms Switch Control在Android上不可见

Man*_*uel 4 android xamarin.forms

我有一个看起来大致相同的注册表

<StackLayout>
    <StackLayout 
        HorizontalOptions="FillAndExpand" 
        Padding="{x:Static local:Styles.LabelBeforeEntryPadding}">
        <Label 
            Text="{Binding LabelPasswort2}" 
            HorizontalOptions="{x:Static local:Styles.LabelHorizontalOptions}" 
            TextColor="{x:Static local:Styles.RegistrationPageTextColor}" />
    </StackLayout>
    <custom:StrypeEntry 
        Text="{Binding Passwort2}" 
        IsPassword="true" 
        IsEnabled="{Binding ControlsEnabled}" 
        HorizontalOptions="FillAndExpand" />
</StackLayout>
<!--Newsletter-->
<StackLayout 
    Orientation="Horizontal" 
    HorizontalOptions="StartAndExpand">
    <Switch 
        IsToggled="{Binding Newsletter}" 
        IsEnabled="{Binding ControlsEnabled}" 
        VerticalOptions="StartAndExpand" 
        HorizontalOptions="StartAndExpand"  />
    <Label 
        Text="{Binding LabelNewsletter}" 
        VerticalOptions="CenterAndExpand" 
        HorizontalOptions="Start" 
        TextColor="{x:Static local:Styles.RegistrationPageTextColor}" />
</StackLayout>
<!--Datenschutz-->
<StackLayout 
    Orientation="Horizontal" 
    HorizontalOptions="StartAndExpand">
    <custom:StrypeSwitch 
        IsToggled="{Binding Privacy}" 
        IsEnabled="{Binding ControlsEnabled}" 
        VerticalOptions="StartAndExpand" 
        HorizontalOptions="StartAndExpand" />
    <Label 
        Text="{Binding LabelPrivacy}" 
        VerticalOptions="CenterAndExpand" 
        HorizontalOptions="Start" 
        WidthRequest="300" TextColor="{x:Static local:Styles.RegistrationPageTextColor}" />
</StackLayout>
Run Code Online (Sandbox Code Playgroud)

问题是,在显示表单时,开关不可见,它们仅在条目聚焦时才可见.

StrypeEntry只是一个带有Border Corder的自定义条目和一个大写的道具,没有任何花哨的东西,而且为了切换我做了一个自定义渲染器来修复不显示的问题.

我已经尝试了ButtonText Alignment的修复程序没有帮助(Xamarin.Forms:点击后错误的按钮文本对齐(Android))

我也尝试过这个

public override void ChildDrawableStateChanged(View child)
{
    base.ChildDrawableStateChanged(child);

    Control.Text = Control.Text;
    Control.Checked = Control.Checked;
}
Run Code Online (Sandbox Code Playgroud)

但仍无法解决

(我正在使用Android 4.4.2测试GT-I9505.Xamarin.Forms程序集的版本是1.2.2.0)

请帮帮我,谢谢

Man*_*uel 8

好像我必须回答我自己的问题.

我通过在xaml中向Switch添加Height-和WidthRequest来修复此问题

希望这有助于其他人.也许如果您找到更好的解决方案,请告诉我.

问候〜