Android:在白色背景上时,switchcompat 跟踪不可见

Android: track invisible for switchcompat when on white background

我有一个背景为白色的 activity,我添加了一个 switchcompat,但是当开关未激活(关闭)时,轨道是不可见的。所有可见的都是拇指,因此用户根本看不出它是一个开关。当开关处于非活动位置时,如何使开关的轨道可见?

                    <android.support.v7.widget.SwitchCompat
                        android:id="@+id/someswitchname"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentRight="true"
                        android:layout_alignParentEnd="true"
                        />

这样做的方法是像这样定义一个自定义主题:

<style name="Custom.SwitchCompat.WhiteTrack" parent="Base.Widget.AppCompat.CompoundButton.Switch">
        <!-- Inactive track color(30% transparency) -->
        <item name="android:colorForeground">[some color]</item>
    </style>

然后像这样在布局中定义主题:

android:theme="@style/Custom.SwitchCompat.WhiteTrack"

瞧瞧。