我正在使用浮动图标和NavigationDrawer
,但是当我打开抽屉时,浮动图标的动画没有关闭,它们保持打开状态,而当我使用alpha 1-slideOffset
时,图标却隐藏了,但是在单击时应该如何操作抽屉打开时我要完全关闭动画吗?
我也在使用不同的SDK
设备。是否可以对所有设备使用相同的代码?
这是我尝试过的:
private void initUi() {
fab_1 = (FloatingMenuButton) findViewById(R.id.fab_1);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(150)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(150)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(150)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(150)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(160)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(200)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(200)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(350)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(500)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(250)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
fab_1.setStartAngle(0)
.setEndAngle(360)
.setRadius(150)
.setAnimationType(AnimationType.EXPAND)
.setMovementStyle(MovementStyle.FREE);
}
fab_1.getAnimationHandler()
.setOpeningAnimationDuration(500)
.setClosingAnimationDuration(200)
.setLagBetweenItems(0)
.setOpeningInterpolator(new FastOutSlowInInterpolator())
.setClosingInterpolator(new FastOutLinearInInterpolator())
.shouldFade(false)
.shouldScale(true)
.shouldRotate(false);
Poultry= (FloatingSubButton) findViewById(R.id.fab_1_sub_fab_left_1);
Poultry.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(FloatingActivity.this, PoultryActivity.class);
startActivity(intent);
}
});
//Navigation Drawer
dl = (DrawerLayout)findViewById(R.id.activity_main);
t = new ActionBarDrawerToggle(this, dl, R.string.Open,
R.string.Close){
public void onDrawerClosed(View view) {
// Visible/Enable the FAB
}
public void onDrawerOpened(View drawerView) {
// Hide/Disable the FAB
}
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
// invert the slideOffset value
fab_1.setAlpha((1/255)*slideOffset);
}
};
dl.addDrawerListener(t);
t.syncState();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
nv = (NavigationView)findViewById(R.id.nv);
nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
int id=item.getItemId();
if (id == R.id.account){
Intent intent = (new Intent(FloatingActivity.this, ComplaintSplash.class));
startActivity(intent);
}
switch(id)
{
case R.id.account:
Toast.makeText(FloatingActivity.this, "Complain ",Toast.LENGTH_SHORT).show();
case R.id.settings:
Toast.makeText(FloatingActivity.this, "Commissioner Karachi Division",Toast.LENGTH_SHORT).show();
case R.id.mycart:
Toast.makeText(FloatingActivity.this, "About Consumer Rights Council",Toast.LENGTH_SHORT).show();
case R.id.PrivacyPolicy:
Toast.makeText(FloatingActivity.this, "Privacy Policy",Toast.LENGTH_SHORT).show();
default:
return true;
}
}
});
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(t.onOptionsItemSelected(item))
return true;
return super.onOptionsItemSelected(item);
}
}
答案 0 :(得分:0)
使用此代码时已解决的问题
ondraweropen ...
$data = [
'mynumber' => (double)number_format(2.733, 2, ".", "")
];
return view('pages.admin.buy', $data);