本文整理汇总了Java中android.support.design.widget.FloatingActionButton.getLayoutParams方法的典型用法代码示例。如果您正苦于以下问题:Java FloatingActionButton.getLayoutParams方法的具体用法?Java FloatingActionButton.getLayoutParams怎么用?Java FloatingActionButton.getLayoutParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.FloatingActionButton
的用法示例。
在下文中一共展示了FloatingActionButton.getLayoutParams方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNestedScroll
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void onNestedScroll(@NonNull CoordinatorLayout coordinatorLayout,
@NonNull FloatingActionButton child,
@NonNull View target,
int dxConsumed,
int dyConsumed,
int dxUnconsumed,
int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
Log.d("Scrolling", "Up");
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
Log.d("Scrolling", "down");
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
示例2: setFab
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
public void setFab(FloatingActionButton fab) {
ViewGroup.LayoutParams layoutParams = fab.getLayoutParams();
if (layoutParams != null && layoutParams instanceof CoordinatorLayout.LayoutParams) {
CoordinatorLayout.LayoutParams coLayoutParams = (CoordinatorLayout.LayoutParams) layoutParams;
BottomNavBarFabBehaviour bottomNavBarFabBehaviour = new BottomNavBarFabBehaviour();
coLayoutParams.setBehavior(bottomNavBarFabBehaviour);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: onNestedScroll
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
@Override
public void onNestedScroll(CoordinatorLayout coordinatorLayout, FloatingActionButton child, View target, int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
//child -> Floating Action Button
if (dyConsumed > 0) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
int fab_bottomMargin = layoutParams.bottomMargin;
child.animate().translationY(child.getHeight() + fab_bottomMargin).setInterpolator(new LinearInterpolator()).start();
} else if (dyConsumed < 0) {
child.animate().translationY(0).setInterpolator(new LinearInterpolator()).start();
}
}
示例7: 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;
}
示例8: animateOut
import android.support.design.widget.FloatingActionButton; //导入方法依赖的package包/类
private void animateOut(FloatingActionButton fab) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
int bottomMargin = layoutParams.bottomMargin;
fab.animate().translationY(fab.getHeight() + bottomMargin).setInterpolator(new LinearInterpolator()).start();
}