/** * Called when the {@link AppBarLayout}'s layout offset has been changed. This allows * child views to implement custom behavior based on the offset (for instance pinning a * view at a certain y value). * * @param appBarLayout the {@link AppBarLayout} which offset has changed * @param verticalOffset the vertical offset for the parent {@link AppBarLayout}, in px */ @Override publicfinalvoidonOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) { if (verticalOffset == 0) { if (mCurrentState != State.EXPANDED) { onStateChanged(appBarLayout, State.EXPANDED); } mCurrentState = State.EXPANDED; } elseif (Math.abs(verticalOffset) >= appBarLayout.getTotalScrollRange()) { if (mCurrentState != State.COLLAPSED) { onStateChanged(appBarLayout, State.COLLAPSED); } mCurrentState = State.COLLAPSED; } else { if (mCurrentState != State.IDLE) { onStateChanged(appBarLayout, State.IDLE); } mCurrentState = State.IDLE; } }
publicabstractvoidonStateChanged(AppBarLayout appBarLayout, State state); }
写完布局的时候,run的时候遇到了一个错误:“**The style on this component requires your app theme to be Theme.AppCompat (or a descendant)**”,有点奇怪。
大致错误如下:
1 2 3 4 5 6
Caused by: android.view.InflateException: Binary XML file line #100in xxx_layout: Binary XML file line #100in xxx_layout: Error inflating class com.google.android.material.XXX Caused by: android.view.InflateException: Binary XML file line #100in xxx_layout: Error inflating class com.google.android.material.XXX Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Constructor.newInstance0(Native Method) ... Caused by: java.lang.IllegalArgumentException: The style on this component requires your app theme to be Theme.AppCompat (or a descendant).
E/VivoSystemReflect: Failure register UserProfilingManager java.lang.ClassNotFoundException: com.vivo.services.userprofiling.UserProfilingManager at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:400) at java.lang.Class.forName(Class.java:326) at android.app.VivoSystemReflect.getServiceConstructor(VivoSystemReflect.java:461) at android.app.VivoSystemReflect.-wrap0(VivoSystemReflect.java) at android.app.VivoSystemReflect$6.createService(VivoSystemReflect.java:446) at android.app.SystemServiceRegistry$CachedServiceFetcher.getService(SystemServiceRegistry.java:858) at android.app.SystemServiceRegistry.getSystemService(SystemServiceRegistry.java:799) at android.app.ContextImpl.getSystemService(ContextImpl.java:1518) at android.content.ContextWrapper.getSystemService(ContextWrapper.java:659) at android.app.Application.getVivoUserProfilingManager(Application.java:327) at android.app.Activity.onResume(Activity.java:1287) at android.support.v4.app.FragmentActivity.onResume(FragmentActivity.java:514) at com.qihoo.browser.activity.ActivityBase.onResume(ActivityBase.kt:117) at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1276) at android.app.Activity.performResume(Activity.java:6963) at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3469)