本文整理汇总了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;
}