我已将项目迁移至
如果我将
无论是哪种情况,我的
AndroidX
。我的MainActivity
继承了FragmentActivity
,但是我的第一个SwitchCompat
看起来全是白色的,第一次进入该屏幕时没有任何颜色。SwitchCompat is white。其下所有其他的SwitchCompact
都有正确的颜色。如果我按返回键并再次回到该屏幕,我的第一个SwitchCompact
会获得正确的颜色并显示正常。如果我将
MainActivity
改为继承AppCompatActivity
,那么当我第一次到达该屏幕时一切都没问题。有人知道这里的问题在哪里吗?因为在迁移之前,我的MainActivity
也继承了FragmentActivity
,一切都很好。无论是哪种情况,我的
xml
代码都是相同的。 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".BlankFragment">
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>