public class CustomActionMenuView extends ActionMenuView {
public CustomActionMenuView(Context context) {
super(context);
}
public CustomActionMenuView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomActionMenuView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int width = MeasureSpec.getSize(widthMeasureSpec);
int height = MeasureSpec.getSize(heightMeasureSpec);
int overflowWidth = getChildAt(getChildCount()-1).getMeasuredWidth();
setMeasuredDimension(width - overflowWidth, height);
}
}
actionMenuView.setOverflowIcon(ContextCompat.getDrawable(this, R.drawable.ic_overflow));