|
|
@@ -3,6 +3,7 @@ package com.mgtech.base_library.custom;
|
|
|
import android.content.Context;
|
|
|
import android.content.res.TypedArray;
|
|
|
import android.graphics.Color;
|
|
|
+import android.graphics.Typeface;
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.util.TypedValue;
|
|
|
@@ -74,6 +75,8 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
|
|
|
TypedArray typedArray = context.obtainStyledAttributes(attrs,R.styleable.MyTitleView,defStyleAttr,0);
|
|
|
bgLayout.setBackgroundColor(typedArray.getColor(R.styleable.MyTitleView_title_bg_color, Color.WHITE));
|
|
|
titleText.setText(typedArray.getText(R.styleable.MyTitleView_title_text));
|
|
|
+ titleText.setTextSize(TypedValue.COMPLEX_UNIT_PX,typedArray.getDimension(R.styleable.MyTitleView_title_text_size
|
|
|
+ ,titleText.getTextSize()));
|
|
|
rightText.setText(typedArray.getText(R.styleable.MyTitleView_title_right_text));
|
|
|
rightText.setTextColor(typedArray.getColor(R.styleable.MyTitleView_title_right_text_color,Color.BLACK));
|
|
|
rightText.setTextSize(TypedValue.COMPLEX_UNIT_PX,typedArray.getDimension(R.styleable.MyTitleView_title_right_text_size
|
|
|
@@ -83,6 +86,15 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
|
|
|
titleText.setTextColor(typedArray.getColor(R.styleable.MyTitleView_title_text_color, Color.BLACK));
|
|
|
centerImage.setBackground(typedArray.getDrawable(R.styleable.MyTitleView_center_image));
|
|
|
setConstraintSet(typedArray.getInt(R.styleable.MyTitleView_title_text_gravity,0));
|
|
|
+
|
|
|
+ int type = typedArray.getInt(R.styleable.MyTitleView_title_text_style,10);
|
|
|
+ if (type == 10){//normal
|
|
|
+ titleText.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
|
|
|
+ } else if (type == 20){//bold
|
|
|
+ titleText.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
|
|
|
+ } else if (type == 30){//italic
|
|
|
+ titleText.setTypeface(Typeface.defaultFromStyle(Typeface.ITALIC));
|
|
|
+ }
|
|
|
typedArray.recycle();
|
|
|
leftImage.setOnClickListener(this);
|
|
|
rightImage.setOnClickListener(this);
|