package com.live.mylivewallpaper.help; import android.content.Context; import android.content.res.TypedArray; import android.util.AttributeSet; import androidx.annotation.Nullable; import com.live.mylivewallpaper.App; import com.live.mylivewallpaper.R; public class MyTextView extends androidx.appcompat.widget.AppCompatTextView { public MyTextView(Context context, @Nullable AttributeSet attrs) { super(context, attrs); initAttrs(context,attrs); } private void initAttrs(Context context, AttributeSet attrs){ TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyTextView); boolean aBoolean = typedArray.getBoolean(R.styleable.MyTextView_apply_font,false); if(aBoolean){ setTypeface(App.getDefaultFont()); } typedArray.recycle(); } }