MyLiveWallpaper/app/src/main/java/com/live/mylivewallpaper/help/MyTextView.java
litingting 3dab1d77c9 init
2024-12-21 11:03:46 +08:00

37 lines
856 B
Java

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