2016-12-27 60 views

回答

0

店浮動操作按鈕時,需要它來恢復按鈕到原來的位置這樣

LayoutParams positionOfButton = floatingActionButton.getLayoutParams(); 

,並再次移動之前以前的位置做到這一點,

floatingActionButton.setLayoutParams(positionOfButton); 
0

你可以做到這一點使用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.