當前位置: 首頁>>代碼示例>>Java>>正文


Java FloatingActionButton.getLayoutParams方法代碼示例

本文整理匯總了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();
    }
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:22,代碼來源:ScrollAwareFABBehavior.java

示例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);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:BottomNavigationBar.java

示例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;
}
 
開發者ID:feup-infolab,項目名稱:labtablet,代碼行數:12,代碼來源:ScrollingFABBehavior.java

示例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;
}
 
開發者ID:afiqiqmal,項目名稱:My-Android-Base-Code,代碼行數:12,代碼來源:ScrollingFABBehavior.java

示例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;
}
 
開發者ID:duyp,項目名稱:mvvm-template,代碼行數:39,代碼來源:FloatingActionButtonBehavior.java

示例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();
    }
}
 
開發者ID:goutham106,項目名稱:GmArchMvvm,代碼行數:14,代碼來源:FAB_Float_on_Scroll.java

示例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;
}
 
開發者ID:ukevgen,項目名稱:BizareChat,代碼行數:13,代碼來源:ScrollingFABBehavior.java

示例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();
}
 
開發者ID:Luodian,項目名稱:Shared-Route,代碼行數:6,代碼來源:FabAnim.java


注:本文中的android.support.design.widget.FloatingActionButton.getLayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。