Nab*_*ari 2 android toast android-appcompat font-family android-theme
每当我显示时Toast,应用程序崩溃.
如果我使用旧版本的AppCompat库或fontFamily从样式中删除,该应用程序工作正常.
的onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toast.makeText(this, "Test", Toast.LENGTH_SHORT).show(); //line 13
}
Run Code Online (Sandbox Code Playgroud)
相关性:
compile 'com.android.support:appcompat-v7:26.1.0'
Run Code Online (Sandbox Code Playgroud)
AppTheme:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">sans-serif-light</item>
</style>
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪:
引起:java.lang.ArrayIndexOutOfBoundsException:length = 16; 在android.content.res.X.B.Adray.loadStringValueAt的android.content.res.XmlBlock $ Parser.getPooledString(XmlBlock.java:458)的android.content.res.StringBlock.get(StringBlock.java:65)索引= 233 TypedArray.java:1212)在Android.support.v7.widget.TintTypedArray.getString(TintTypedArray.java:143)android.content.res.TypedArray.getString(TypedArray.java:202)的android.support.v7.:347)位于android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:152)的.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:215)位于android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81),位于android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater)的android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71). java:103)在android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1024))android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)的android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:769)上的android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1081)在android.view.LayoutInflater.rInflate(LayoutInflater.java:858)的android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)在android.view上的android.view.LayoutInflater.inflate(LayoutInflater.java:518). LayoutInflater.inflate(LayoutInflater.java:426)位于android.view.LayoutInflater.inflate(LayoutInflater.java:377)的android.widget.Toast.makeText(Toast.java:266)at io.yarsa.blankapp.MainActivity.onCreate (MainActivity.java:13)在android.app.Anstrumentation.callActivityOnCreate(Instrumentation.java:1119)android.app.ActivityThread.performLaunchActivity(ActivityThread.java)的android.app.Activity.performCreate(Activity.java:6679). 2618)在Android.app.A的android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)android.app.Loper.loop上的android.app.A.运行时,Android.O.运行时,运行android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1477)的ctivityThread.-wrap12(ActivityThread.java)(Handler.java:102) Looper.java:154)在android.app.ActivityThread.main(ActivityThread.java:6126)的java.lang.reflect.Method.invoke(Native Method)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run( ZygoteInit.java:886)at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
有没有其他选择,以便我可以使用fontFamily最新版本的AppCompat库在主题中使用该属性?
小智 8
在主题中添加字体如下 -
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<item name="android:textViewStyle">@style/TextViewStyle</item>
<item name="android:buttonStyle">@style/ButtonStyle</item>
</style>
<style name="TextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>
<style name="ButtonStyle" parent="Widget.AppCompat.Button">
<item name="android:fontFamily">sans-serif-light</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
742 次 |
| 最近记录: |