Android-skin-support icon indicating copy to clipboard operation
Android-skin-support copied to clipboard

这个会今日头条那个屏幕适配失效,怎么解决

Open itzj90 opened this issue 4 years ago • 3 comments

itzj90 avatar Jul 02 '20 06:07 itzj90

参考自定义view换肤,实现下

ximsfei avatar Jul 03 '20 13:07 ximsfei

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;
    }

miserydx avatar Jul 27 '20 09:07 miserydx

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;
    }

遇到了同样的问题,吧上面代码屏蔽了也没有用

fengqingyun2008 avatar Jan 12 '21 04:01 fengqingyun2008