使用TabLayout遇到的坑

出现问题导致不能编译

Caused by: android.view.InflateException: Binary XML file line # 8 : Error inflating class android.support.design.widget.TabLayout
         at android.view.LayoutInflater.createView(LayoutInflater.java: 633 )
         at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java: 743 )
         at android.view.LayoutInflater.rInflate(LayoutInflater.java: 806 )
         at android.view.LayoutInflater.inflate(LayoutInflater.java: 504 )
         at android.view.LayoutInflater.inflate(LayoutInflater.java: 414 )
         at android.view.LayoutInflater.inflate(LayoutInflater.java: 365 )
         at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java: 377 )
         at android.app.Activity.setContentView(Activity.java: 2144 )
         at com.example.hp.myapplication.MainActivity.onCreate(MainActivity.java: 15 )
         at android.app.Activity.performCreate(Activity.java: 5933 )
解决办法:在项目values包下面的styles文件下修改代码,

<resources><style name= "AppTheme" parent= "Base.AppTheme" type= "text/css" ><!-- Customize your theme here. --></style>
     <!-- Base application theme. --><style name= "Base.AppTheme" parent= "Theme.AppCompat.Light.DarkActionBar" type= "text/css" ><item name= "colorPrimary" >#673AB7</item>
         <item name= "colorPrimaryDark" >#512DA8</item>
         <item name= "colorAccent" >#FF4081</item></style>
 
</resources>


猜你喜欢

转载自blog.csdn.net/forzhers/article/details/79789011