本文整理匯總了Java中android.support.design.widget.FloatingActionButton.setTranslationY方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatingActionButton.setTranslationY方法的具體用法?Java FloatingActionButton.setTranslationY怎麽用?Java FloatingActionButton.setTranslationY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.FloatingActionButton
的用法示例。
在下文中一共展示了FloatingActionButton.setTranslationY方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onDependentViewChanged
import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
if (dependency instanceof AppBarLayout) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
int fabBottomMargin = lp.bottomMargin;
int distanceToScroll = fab.getHeight() + fabBottomMargin;
float ratio = dependency.getY() /(float)toolbarHeight;
fab.setTranslationY(-distanceToScroll * ratio);
}
return true;
}
示例2: onDependentViewChanged
import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
if (dependency instanceof AppBarLayout) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
int fabBottomMargin = lp.bottomMargin;
int distanceToScroll = fab.getHeight() + fabBottomMargin;
float ratio = (float)dependency.getY()/(float)toolbarHeight;
fab.setTranslationY(-distanceToScroll * ratio);
}
return true;
}
示例3: onDependentViewChanged
import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@Override public boolean onDependentViewChanged(@NonNull
final CoordinatorLayout parent, @NonNull
final FloatingActionButton child, final View dependency) {
log(TAG, INFO, "onDependentViewChanged: " + dependency);
final List<View> list = parent.getDependencies(child);
ViewGroup.MarginLayoutParams params = ((ViewGroup.MarginLayoutParams) child.getLayoutParams());
int bottomMargin = (params.bottomMargin + params.rightMargin) - (params.topMargin + params.leftMargin);
float t = 0;
float t2 = 0;
float t3 = 0;
boolean result = false;
for (View dep : list) {
if (Snackbar.SnackbarLayout.class.isInstance(dep)) {
t += dep.getTranslationY() - dep.getHeight();
result = true;
} else if (BottomNavigation.class.isInstance(dep)) {
BottomNavigation navigation = (BottomNavigation) dep;
t2 = navigation.getTranslationY() - navigation.getHeight() + bottomMargin;
t += t2;
result = true;
if (navigationBarHeight > 0) {
if (!navigation.isExpanded()) {
child.hide();
} else {
child.show();
}
}
}
}
if (navigationBarHeight > 0 && t2 < 0) {
t = Math.min(t2, t + navigationBarHeight);
}
child.setTranslationY(t);
return result;
}
示例4: onDependentViewChanged
import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {
boolean returnValue = super.onDependentViewChanged(parent, fab, dependency);
if (dependency instanceof AppBarLayout) {
CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
int fabBottomMargin = lp.bottomMargin;
int distanceToScroll = fab.getHeight() + fabBottomMargin;
float ratio = dependency.getY() / (float) toolbarHeight;
fab.setTranslationY(-distanceToScroll * ratio);
}
return returnValue;
}
示例5: onDependentViewChanged
import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FloatingActionButton child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}