Android-skin-support
Android-skin-support copied to clipboard
这个会今日头条那个屏幕适配失效,怎么解决
参考自定义view换肤,实现下
SkinAppCompatViewInflater中,wrapContext方法会将达到条件的设备的上下文包一层TintContentWrapper,我这里暂时注释这段代码可以解决问题
@Override
public Context wrapContext(Context context, View parent, AttributeSet attrs) {
// final boolean isPre21 = Build.VERSION.SDK_INT < 21;
//
// // We only want the View to inherit its context if we're running pre-v21
// final boolean inheritContext = isPre21 && shouldInheritContext(context, (ViewParent) parent);
//
// // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy
// // by using the parent's context
// if (inheritContext && parent != null) {
// context = parent.getContext();
// }
// boolean readAndroidTheme = isPre21; /* Only read android:theme pre-L (L+ handles this anyway) */
// boolean readAppTheme = true; /* Read read app:theme as a fallback at all times for legacy reasons */
// boolean wrapContext = VectorEnabledTintResources.shouldBeUsed(); /* Only tint wrap the context if enabled */
//
// // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy
// // by using the parent's context
// if (inheritContext && parent != null) {
// context = parent.getContext();
// }
// if (readAndroidTheme || readAppTheme) {
// // We then apply the theme on the context, if specified
// context = themifyContext(context, attrs, readAndroidTheme, readAppTheme);
// }
// if (wrapContext) {
// context = TintContextWrapper.wrap(context);
// }
return context;
}
SkinAppCompatViewInflater中,wrapContext方法会将达到条件的设备的上下文包一层TintContentWrapper,我这里暂时注释这段代码可以解决问题
@Override public Context wrapContext(Context context, View parent, AttributeSet attrs) { // final boolean isPre21 = Build.VERSION.SDK_INT < 21; // // // We only want the View to inherit its context if we're running pre-v21 // final boolean inheritContext = isPre21 && shouldInheritContext(context, (ViewParent) parent); // // // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy // // by using the parent's context // if (inheritContext && parent != null) { // context = parent.getContext(); // } // boolean readAndroidTheme = isPre21; /* Only read android:theme pre-L (L+ handles this anyway) */ // boolean readAppTheme = true; /* Read read app:theme as a fallback at all times for legacy reasons */ // boolean wrapContext = VectorEnabledTintResources.shouldBeUsed(); /* Only tint wrap the context if enabled */ // // // We can emulate Lollipop's android:theme attribute propagating down the view hierarchy // // by using the parent's context // if (inheritContext && parent != null) { // context = parent.getContext(); // } // if (readAndroidTheme || readAppTheme) { // // We then apply the theme on the context, if specified // context = themifyContext(context, attrs, readAndroidTheme, readAppTheme); // } // if (wrapContext) { // context = TintContextWrapper.wrap(context); // } return context; }
遇到了同样的问题,吧上面代码屏蔽了也没有用