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


Java FloatingActionButton.getHeight方法代碼示例

本文整理匯總了Java中android.support.design.widget.FloatingActionButton.getHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java FloatingActionButton.getHeight方法的具體用法?Java FloatingActionButton.getHeight怎麽用?Java FloatingActionButton.getHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.design.widget.FloatingActionButton的用法示例。


在下文中一共展示了FloatingActionButton.getHeight方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateFabTranslationForBottomNavigationBar

import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
private void updateFabTranslationForBottomNavigationBar(CoordinatorLayout parent, FloatingActionButton fab, View dependency) {

        float snackBarTranslation = getFabTranslationYForSnackBar(parent, fab);
        float[] bottomBarParameters = getFabTranslationYForBottomNavigationBar(parent, fab);
        float bottomBarTranslation = bottomBarParameters[0];
        float bottomBarHeight = bottomBarParameters[1];

        float targetTransY = 0;
        if (snackBarTranslation >= bottomBarTranslation) {
            // when snackBar is below BottomBar in translation present.
            targetTransY = bottomBarTranslation;
        } else {
            targetTransY = snackBarTranslation;
        }

//        if (mFabBehaviour == BottomNavigationBar.FAB_BEHAVIOUR_DISAPPEAR) {
//            if (targetTransY == 0) {
//                fab.hide();
//            } else {
//                fab.show();
//            }
//        }

        final float currentTransY = ViewCompat.getTranslationY(fab);

        // Make sure that any current animation is cancelled
        ensureOrCancelAnimator(fab);


        if (fab.isShown()
                && Math.abs(currentTransY - targetTransY) > (fab.getHeight() * 0.667f)) {
            // If the FAB will be travelling by more than 2/3 of it's height, let's animate it instead
            mFabTranslationYAnimator.translationY(targetTransY).start();
        } else {
            // Now update the translation Y
            ViewCompat.setTranslationY(fab, targetTransY);
        }
    }
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:39,代碼來源:BottomNavBarFabBehaviour.java

示例2: revealSides

import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
@OnClick({R.id.first,R.id.third})
public void revealSides(FloatingActionButton dot) {
    if (finished) {
        finished=false;
        lastDot = dot;
        float deltaX = topPanel.getWidth() / 2 - dot.getX() - dot.getWidth() / 2;
        float deltaY = topPanel.getHeight() / 2 - dot.getY() - dot.getHeight() / 2;
        deltaY -= topPanel.getHeight() / 2 + getResources().getDimension(R.dimen.morph_radius) / 4;
        Path arcPath = createArcPath(dot, deltaX, deltaY, -deltaX);
        ValueAnimator pathAnimator = ValueAnimator.ofFloat(0, 1);
        pathAnimator.addUpdateListener(new ArcListener(arcPath, dot));
        int dotColor=dot.getBackgroundTintList().getDefaultColor();
        topPanel.setBackgroundColor(dotColor);
        if(dotColor==color) {
            backgroundReveal().start();
        }
        pathAnimator.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                Animator animator = createRevealAnimator(dot, 0);
                finish(animator);
                animator.start();
                runCloseAnimation();
            }
        });
        AnimatorSet animatorSet = morphParent(duration(R.integer.reveal_duration));
        animatorSet.play(pathAnimator);
        addScaleAnimation(duration(R.integer.short_delay), duration(R.integer.fade_duration), animatorSet);
        animatorSet.start();
    }
}
 
開發者ID:vpaliyX,項目名稱:Material-Motion,代碼行數:33,代碼來源:DotsFragment.java

示例3: createRevealAnimator

import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
private Animator createRevealAnimator(FloatingActionButton dot, float offsetY){
    ViewCompat.setElevation(dot,0);
    dot.setVisibility(View.INVISIBLE);
    lastDot=dot;
    int cx=(int)(dot.getX()+dot.getHeight()/2);
    int cy=(int)(dot.getY()+dot.getHeight()/2+offsetY);
    int w = topPanel.getWidth();
    int h = topPanel.getHeight();
    final int endRadius = !isFolded?(int) Math.hypot(w, h):dot.getHeight()/2;
    final int startRadius=isFolded?(int) Math.hypot(w, h):dot.getHeight()/2;
    topPanel.setVisibility(View.VISIBLE);
    Animator animator= ViewAnimationUtils.createCircularReveal(topPanel,cx,cy,startRadius,endRadius);
    animator.setDuration(duration(R.integer.reveal_duration));
    return animator;
}
 
開發者ID:vpaliyX,項目名稱:Material-Motion,代碼行數:16,代碼來源:DotsFragment.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 = dependency.getY() /(float)toolbarHeight;
        fab.setTranslationY(-distanceToScroll * ratio);
    }
    return true;
}
 
開發者ID:feup-infolab,項目名稱:labtablet,代碼行數:12,代碼來源:ScrollingFABBehavior.java

示例5: 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

示例6: getDyBetweenChildAndDependency

import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
/**
 * In some <bold>WEIRD</bold> cases, mostly when you perform a little scroll but a fast one
 * the {@link #onDependentViewChanged(CoordinatorLayout, FloatingActionButton, View)} DOESN'T
 * reflect the real Y position of child mean the dependency get a better APROXIMATION of the real
 * Y. This was causing that FAB some times doesn't get unhidden.
 * @param child the FAB
 * @param dependency NestedScrollView instance
 * @return Dy betweens those 2 elements in Y, minus child's height/2
 */
private int getDyBetweenChildAndDependency(@NonNull FloatingActionButton child, @NonNull View dependency) {
    if (dependency.getY() == 0 || dependency.getY() < offset)
        return 0;

    if ( (dependency.getY() - child.getY()) > child.getHeight() )
        return Math.max(0, (int) ((dependency.getY() - (child.getHeight()/2)) - child.getY()) );
    else
        return 0;
}
 
開發者ID:aliumujib,項目名稱:Nibo,代碼行數:19,代碼來源:ScrollAwareFABBehavior.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: animation_change_color

import android.support.design.widget.FloatingActionButton; //導入方法依賴的package包/類
public void animation_change_color(int Int) {
    ImageView play_now_back_color = (ImageView) findViewById(R.id.play_now_back_color);
    if (cx == 0) {
        FloatingActionButton play_or_pause = (FloatingActionButton) findViewById(R.id.play_or_pause);
        RelativeLayout seekbar_layout = (RelativeLayout) findViewById(R.id.seekbar_layout);
        RelativeLayout control_layout = (RelativeLayout) findViewById(R.id.control_layout);
        cx = play_or_pause.getLeft() + control_layout.getLeft() + play_or_pause.getWidth() / 2;
        cy = control_layout.getTop() - seekbar_layout.getTop() + play_or_pause.getTop() + play_or_pause.getHeight() / 2;
        finalRadius = Math.max(play_now_back_color.getWidth(), play_now_back_color.getHeight());
    }
    final int Int1 = Int;
    final RelativeLayout activity_now_play = (RelativeLayout) findViewById(R.id.activity_now_play);
    if (cx != 0) {
        Animator anim = ViewAnimationUtils.createCircularReveal(play_now_back_color, cx, cy, 0, finalRadius);
        play_now_back_color.setBackgroundColor(Int);
        anim.setDuration(500);
        anim.start();
        anim.addListener(new AnimatorListenerAdapter() {
            @Override
            public void onAnimationEnd(Animator animation) {
                super.onAnimationEnd(animation);
                activity_now_play.setBackgroundColor(Int1);
            }
        });
    }else{
        activity_now_play.setBackgroundColor(Int1);
    }
    TextView now_on_play_text = (TextView) findViewById(R.id.now_on_play_text);
    now_on_play_text.setTextColor(Int);
    //lrcview字體顏色

    //歌詞背景顏色
    if(Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        View bottom = findViewById(R.id.gradient_bottom);
        View top = findViewById(R.id.gradient_top);
        View gradient = findViewById(R.id.gradient);
        top.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //顏色
                        8, //漸變層數
                        Gravity.TOP)); //起始方向
        bottom.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //顏色
                        8, //漸變層數
                        Gravity.BOTTOM)); //起始方向
        gradient.setBackground(
                ScrimUtil.makeCubicGradientScrimDrawable(Int1, //顏色
                        8, //漸變層數
                        Gravity.BOTTOM)); //起始方向
    }
}
 
開發者ID:htqqdd,項目名稱:music_player,代碼行數:51,代碼來源:MainActivity.java


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