0
大小自動增加當點擊任何按鈕的圖標將不棒棒糖大小時,我在浮動按鈕改變圖標會自動增加,當我在浮動按鈕<br> 改變圖標,這是我的代碼 當我在任何菜單第一次大小增加然後單擊後一切都很好 我想
fab = (FloatingActionButton)findViewById(R.id.fab);
fab1 = (FloatingActionButton)findViewById(R.id.fab1);
fab2 = (FloatingActionButton)findViewById(R.id.fab2);
fab_open = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fab_open);
fab_close = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.fab_close);
rotate_forward = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_forward);
rotate_backward = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.rotate_backward);
fab.setOnClickListener(this);
fab1.setOnClickListener(this);
fab2.setOnClickListener(this);
}
@Override
public void onClick(View v) {
int id = v.getId();
switch (id){
case R.id.fab:
animateFAB();
break;
case R.id.fab1:
toggle();
Log.d("Raj", "Fab 1");
break;
case R.id.fab2:
Log.d("Raj", "Fab 2");
break;
}
}
private void toggle() {
if(isopen) {
isopen=false;
fab1.setImageResource(R.drawable.ic_3d_rotation_black_18dp);
}else {
isopen=true;
fab1.setImageResource(R.drawable.ic_3d_rotation_white_18dp);
}
}
public void animateFAB(){
if(isFabOpen){
fab.startAnimation(rotate_backward);
fab1.startAnimation(fab_close);
fab2.startAnimation(fab_close);
fab1.setClickable(false);
fab2.setClickable(false);
isFabOpen = false;
Log.d("Raj", "close");
} else {
fab.startAnimation(rotate_forward);
fab1.startAnimation(fab_open);
fab2.startAnimation(fab_open);
fab1.setClickable(true);
fab2.setClickable(true);
isFabOpen = true;
Log.d("Raj", "open");
}
}
}