老师 我想问 如果主按钮 在中间 item呈180°散开 怎么做
老师 我想问 如果主按钮 在中间 item呈180°散开 怎么做
老师 我想问 如果主按钮 在中间 item呈180°散开 怎么做
2017-01-02
散开路径:
int l1 = (int) (mRadius * Math.sin(Math.PI / count * (i + 1)));
int t1= (int) (mRadius * Math.cos(Math.PI / count * (i + 1)));
int xflag = 1;
int yflag = 1;
AnimationSet animset = new AnimationSet(true);
Animation tranAnim = null;
if (mCurrentStatus == Status.CLOSE)
{
tranAnim = new TranslateAnimation(xflag * t1, 0, yflag * l1, 0);
childView.setClickable(true);
childView.setFocusable(true);
}
else
{
tranAnim = new TranslateAnimation(0, xflag * t1, 0, yflag * l1);
childView.setClickable(false);
childView.setFocusable(false);
}主菜单和子菜单定位:
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (changed){
layoutCButton();
int count = getChildCount();
for (int i=0;i<count-1;i++){
View child = getChildAt(i+1);
child.setVisibility(View.GONE);
int t1 = (int) (mRadius * Math.sin(Math.PI / count * (i + 1)));
int l1= (int) (mRadius * Math.cos(Math.PI / count * (i + 1)));
int width = child.getMeasuredWidth();
int height = child.getMeasuredHeight();
l = getMeasuredWidth() / 2 - width / 2 - l1;
t = getMeasuredHeight() - height - t1;
child.layout(l, t, l + width, t + height);
}
}
}
private void layoutCButton() {
mCButton = getChildAt(0);
mCButton.setOnClickListener(this);
int l = 0;
int t = 0;
int width = mCButton.getMeasuredWidth();
int height = mCButton.getMeasuredHeight();
switch (mPosition){
case CENTER:
l = getMeasuredWidth() / 2 - width / 2;
t = getMeasuredHeight() - height;
break;
}
mCButton.layout(l, t, l + width, t + height);
}举报