|
|
@@ -12,6 +12,7 @@ import android.widget.ImageView;
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
|
+import androidx.constraintlayout.widget.ConstraintSet;
|
|
|
|
|
|
import com.mgtech.base_library.R;
|
|
|
import com.mgtech.base_library.util.DrawableUtil;
|
|
|
@@ -40,6 +41,7 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
|
|
|
protected RightTextClickListener rightTextClickListener;
|
|
|
|
|
|
private Context context;
|
|
|
+ private ConstraintSet constraintSet;
|
|
|
|
|
|
public MyTitleView(Context context) {
|
|
|
this(context,null);
|
|
|
@@ -80,11 +82,24 @@ public class MyTitleView extends ConstraintLayout implements View.OnClickListene
|
|
|
rightImage.setImageResource(typedArray.getResourceId(R.styleable.MyTitleView_right_image, 0));
|
|
|
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));
|
|
|
typedArray.recycle();
|
|
|
leftImage.setOnClickListener(this);
|
|
|
rightImage.setOnClickListener(this);
|
|
|
rightText.setOnClickListener(this);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private void setConstraintSet(int type){
|
|
|
+ if (type == 0)
|
|
|
+ return;
|
|
|
+ if (constraintSet == null)
|
|
|
+ constraintSet = new ConstraintSet();
|
|
|
+ constraintSet.clone(bgLayout);
|
|
|
+ constraintSet.connect(R.id.title_text,ConstraintSet.END,R.id.right_image,ConstraintSet.START);
|
|
|
+ constraintSet.applyTo(bgLayout);
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View view) {
|
|
|
int i = view.getId();
|