public View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs) { final boolean isPre21 = Build.VERSION.SDK_INT < 21; if (mSkinCompatViewInflater == null) { mSkinCompatViewInflater = new SkinCompatViewInflater(); } // We only want the View to inherit its context if we're running pre-v21 final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent); return mSkinCompatViewInflater.createView(parent, name, context, attrs, inheritContext, isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */ true, /* Read read app:theme as a fallback at all times for legacy reasons */ VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */ ); }
public View createView(View parent, final String name, @NonNull Context context, @NonNull AttributeSet attrs) { final boolean isPre21 = Build.VERSION.SDK_INT < 21; if (mAppCompatViewInflater == null) { mAppCompatViewInflater = new SkinAppCompatViewInflater(); } // We only want the View to inherit its context if we're running pre-v21 final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent); return mAppCompatViewInflater.createView(parent, name, context, attrs, inheritContext, isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */ true, /* Read read app:theme as a fallback at all times for legacy reasons */ VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */ ); }
/** * Sets the scaling factor for fonts displayed on the display. * * @param scale the scaling factor. */ public static void setScaledDensity(Context context, float scale) { Resources resources = context.getApplicationContext().getResources(); DisplayMetrics displayMetrics = resources.getDisplayMetrics(); Resources sysResources = Resources.getSystem(); displayMetrics.scaledDensity = sysResources.getDisplayMetrics().scaledDensity * scale; //if use vector drawable, and SDK <= 20, use this to compat if (VectorEnabledTintResources.shouldBeUsed()) { Configuration config = resources.getConfiguration(); config.fontScale = sysResources.getConfiguration().fontScale * scale; //noinspection deprecation resources.updateConfiguration(config, displayMetrics); } }
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { try { View view = mAppCompatDelegate.createView(parent, name, context, attrs); if (view == null) { final boolean isPre21 = Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP; final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent); view = mCompatInflater.createView(parent, name, context, attrs, inheritContext, isPre21, VectorEnabledTintResources.shouldBeUsed()); } if (view instanceof TextView) { RobotoTypefaces.setUpTypeface((TextView) view, context, attrs); } return view; } catch (Exception e) { //if some thing went wrong return null; } }
@Override public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { if (mSkinnableViewInflater == null) { mSkinnableViewInflater = new SkinnableViewInflater(); } final boolean isPre21 = Build.VERSION.SDK_INT < 21; final boolean inheritContext = isPre21 && shouldInheritContext((ViewParent) parent); return mSkinnableViewInflater.createView(parent, name, context, attrs, inheritContext, isPre21, /* Only read android:theme pre-L (L+ handles this anyway) */ true, /* Read read app:theme as a fallback at all times for legacy reasons */ VectorEnabledTintResources.shouldBeUsed() /* Only tint wrap the context if enabled */ ); }
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) { final boolean isPre21 = Build.VERSION.SDK_INT < 21; return createView(parent, name, context, attrs, false, false, isPre21, VectorEnabledTintResources.shouldBeUsed()); }
@Override public View onCreateView(String name, Context context, AttributeSet attrs) { final boolean isPre21 = Build.VERSION.SDK_INT < 21; return createView(null, name, context, attrs, false, false, isPre21, VectorEnabledTintResources.shouldBeUsed()); }