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