//自定义标题栏
public class MyTitleView extends LinearLayout implements View.OnClickListener{
public MyTitleView(Context context) {
super(context);
}
public MyTitleView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.MyTitleView);
String text = typedArray.getString(R.styleable.MyTitleView_title_text);
String left = typedArray.getString(R.styleable.MyTitleView_title_left_btn);
String right = typedArray.getString(R.styleable.MyTitleView_title_right_btn);
View inflate = inflate(context, R.layout.main_item, this);
TextView title = inflate.findViewById(R.id.tv_title);
Button btn1=inflate.findViewById(R.id.left_btn);
Button btn2=inflate.findViewById(R.id.right_btn);
title.setText(text);
title.setTextColor(Color.BLACK);
btn1.setText(left);
btn2.setText(right);
title.setOnClickListener(this);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.left_btn:
if (onBtnOnclick!=null){
onBtnOnclick.getLeftBtn();
}
break;
case R.id.right_btn:
if (onBtnOnclick!=null){
onBtnOnclick.getRightBtn();
}
break;
case R.id.tv_title:
if (onBtnOnclick!=null){
onBtnOnclick.getText();
}
break;
}
}
public interface onBtnOnclick{
void getLeftBtn();
void getRightBtn();
void getText();
}
private onBtnOnclick onBtnOnclick;
public void setOnBtnOnclick(onBtnOnclick onBtnOnclick){
this.onBtnOnclick=onBtnOnclick;
}
}
//梯形布局
public class FlowLayout extends ViewGroup{
private int widthSize;
public FlowLayout(Context context) {
super(context);
}
public FlowLayout(Con