遇到问题集合

1. 小米全面屏手机18:9屏幕适配


一、声明最大屏幕高宽比

在应用配置文件AndroidManifest.xml中显式声明支持的最大屏幕高宽比(maximum aspect ratio)。其中 ratio_float 为高宽比:
传统屏幕:ratio_float = 16/9 = 1.778 ;
三星S8屏幕:ratio_float = 18.5/9 = 2.056。
鉴于目前全面屏屏幕比例,将ratio_float设置为2.1即可适配一众全面屏手机。

data 
  android:name="android.max_aspect"
  android:value="ratio_float" />

2. v7 包 与recyclerview 包 版本不一致问题

错误日志:

    java.lang.NoSuchMethodError: No static method getFont(Landroid/content/Context;ILandroid/util/TypedValue;ILandroid/widget/TextView;)Landroid/graphics/Typeface; in class Landroid/support/v4/content/res/ResourcesCompat; or its super classes (declaration of 'android.support.v4.content.res.ResourcesCompat' appears in /data/app/com.zyh.imageEditor-1/base.apk)
                                                     at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)
                                                     at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)
                                                     at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:110)
                                                     at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)
                                                     at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:81)
                                                     at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:71)
                                                     at android.support.v7.widget.AppCompatTextView.(AppCompatTextView.java:67)
                                                     at android.support.v7.widget.Toolbar.setTitle(Toolbar.java:753)
                                                     at android.support.v7.widget.ToolbarWidgetWrapper.setTitleInt(ToolbarWidgetWrapper.java:261)
                                                     at android.support.v7.widget.ToolbarWidgetWrapper.setWindowTitle(ToolbarWidgetWrapper.java:243)
                                                     at android.support.v7.widget.ActionBarOverlayLayout.setWindowTitle(ActionBarOverlayLayout.java:621)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.onTitleChanged(AppCompatDelegateImplV9.java:631)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.ensureSubDecor(AppCompatDelegateImplV9.java:328)
                                                     at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:284)
                                                     at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
                                                     at com.zyh.imageEditor.MainActivity.onCreate(MainActivity.java:23)
                                                     at android.app.Activity.performCreate(Activity.java:6093)
                                                     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
                                                     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2295)
                                                     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2404)
                                                     at android.app.ActivityThread.access$900(ActivityThread.java:154)
                                                     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1315)
                                                     at android.os.Handler.dispatchMessage(Handler.java:102)
                                                     at android.os.Looper.loop(Looper.java:135)
                                                     at android.app.ActivityThread.main(ActivityThread.java:5296)
                                                     at java.lang.reflect.Method.invoke(Native Method)
                                                     at java.lang.reflect.Method.invoke(Method.java:372)
                                                     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:912)
                                                     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:707)

错误原因:

遇到问题集合_第1张图片

解决方法:

只要将RecyclerView cardview 版本修改成与V7包一致即可运行

你可能感兴趣的:(错误)