抱歉,聚会晚了,但是此答案可能对希望启用标志AppCompatDelegate.setCompatVectorFromResourcesEnabled(true)的用户有所帮助。所有活动。
1.创建一个扩展到应用程序的类(android.app.Application)
public class MyApplicationClass extends Application
{
@Override
public void onCreate()
{
super.onCreate();
}
}
2.转到Manifest.xml并将以下行添加到标签中
<application
android:name=".MyApplicationClass"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
...
</application>
3.在MyApplicationClass.java的onCreate上方添加以下代码
// This flag should be set to true to enable VectorDrawable support for API < 21
static
{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
MyApplicationClass.java的完整代码
import android.app.Application;
import android.support.v7.app.AppCompatDelegate;
public class MyApplicationClass extends Application
{
static
{
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
@Override
public void onCreate()
{
super.onCreate();
}
}