0
我想在应用程序关闭时保留浮动动作按钮的位置,并在应用程序再次打开时再次在前一个位置显示FAB。保留以前的浮动动作按钮的位置android
我想在应用程序关闭时保留浮动动作按钮的位置,并在应用程序再次打开时再次在前一个位置显示FAB。保留以前的浮动动作按钮的位置android
店浮动操作按钮时,需要它来恢复按钮到原来的位置这样
LayoutParams positionOfButton = floatingActionButton.getLayoutParams();
,并再次移动之前以前的位置做到这一点,
floatingActionButton.setLayoutParams(positionOfButton);
你可以做到这一点使用sharedPreferences概念。您必须捕捉FAB的坐标并将其存储在偏好中。
SharedPreferences sp=getSharedPreferences("values",0);
int[] i=new int[2];
FAB.getLocationOnScreen(i);
sp.edit().putString(i[0]+"").commit();
sp.edit().putString(i[1]+"").commit();
//while retrieving parse to double. and then set
FAB.setX(x);
FAB.setY(y); //where x and y are double values from sharedpreferences.
请分享您的验证码 – Raghunandan