When I am expanding floating action button it keep remain expanded until I click on that again to collapse.
My question is there any way to automatically collapse floating action button after some times from expanding state.
When I am expanding floating action button it keep remain expanded until I click on that again to collapse.
My question is there any way to automatically collapse floating action button after some times from expanding state.
Use a Handler with a delay:
public class HideFabActivity extends AppCompatActivity{
private final int DELAY = 5000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final FloatingActionButton fab =(FloatingActionButton)findViewById(R.id.fab);
new Handler().postDelayed(new Runnable(){
@Override
public void run() {
fab.hide();
}
}, DELAY);
}
Check out this SO post re using Handler to make a Splash page.