当前位置: 首页>>代码示例>>Java>>正文


Java FloatingActionButton.setTranslationY方法代码示例

本文整理汇总了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;
}
 
开发者ID:feup-infolab,项目名称:labtablet,代码行数:12,代码来源:ScrollingFABBehavior.java

示例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;
}
 
开发者ID:afiqiqmal,项目名称:My-Android-Base-Code,代码行数:12,代码来源:ScrollingFABBehavior.java

示例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;
}
 
开发者ID:duyp,项目名称:mvvm-template,代码行数:39,代码来源:FloatingActionButtonBehavior.java

示例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;
}
 
开发者ID:ukevgen,项目名称:BizareChat,代码行数:13,代码来源:ScrollingFABBehavior.java

示例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;
}
 
开发者ID:HStanN,项目名称:TakeRest,代码行数:7,代码来源:FABBehavior.java


注:本文中的android.support.design.widget.FloatingActionButton.setTranslationY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。