Java Code Examples for android.support.design.widget.FloatingActionButton#getMeasuredHeight()
The following examples show how to use
android.support.design.widget.FloatingActionButton#getMeasuredHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FabSheetWindow.java From android-md-core with Apache License 2.0 | 5 votes |
FabInfo(FloatingActionButton fab) { int[] location = new int[2]; fab.getLocationInWindow(location); width = fab.getMeasuredWidth(); height = fab.getMeasuredHeight(); topLeft = new Pointer(location[0], location[1]); center = new Pointer(topLeft.x + width / 2, topLeft.y + height / 2); bottomRight = new Pointer(topLeft.x + width, topLeft.y + height); relativeTopLeft = new Pointer(ViewCompat.getX(fab), ViewCompat.getY(fab)); relativeCenter = new Pointer(relativeTopLeft.x + width / 2, relativeTopLeft.y + height / 2); relativeBottomRight = new Pointer(relativeTopLeft.x + width, relativeTopLeft.y + height); radius = Math.min(width / 2, MdCompat.dpToPx(FAB_SIZE)); }
Example 2
Source File: FloatingActionMenu.java From MaterialWpp with Apache License 2.0 | 4 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { System.out.println("onLayout:" + changed); if (changed) { int right = r - getPaddingRight(); int bottom = b - getPaddingBottom(); int top = bottom - mMenuButton.getMeasuredHeight(); mMenuButton.layout(right - mMenuButton.getMeasuredWidth(), top, right, bottom); int dw = (mMenuButton.getMeasuredWidth() - mIcon.getMeasuredWidth()) / 2; int dh = (mMenuButton.getMeasuredHeight() - mIcon.getMeasuredHeight()) / 2; mIcon.layout(right - mIcon.getMeasuredWidth() - dw, bottom - mIcon.getMeasuredHeight() - dh, right - dw, bottom - dh); if (isCircle) { if (mMenuItems.size() < 2) { Log.e("onLayout", "Floating Action Buttons must more then one!"); return; } double angle = Math.PI/2d/(mMenuItems.size() - 1); for (int i = 0; i < mMenuItems.size(); i++) { FloatingActionButton itemFB = mMenuItems.get(i); int fbWidth = itemFB.getMeasuredWidth(); int fbHeight = itemFB.getMeasuredHeight(); if (0 != multipleOfFB) { mRadius = (int) (fbWidth * multipleOfFB); } int itemDw = (mMenuButton.getMeasuredWidth() - fbWidth) / 2; int itemDh = (mMenuButton.getMeasuredHeight() - fbHeight) / 2; int itemX = (int) (mRadius*Math.cos(i*angle)); int itemY = (int) (mRadius*Math.sin(i*angle)); itemFB.layout(right - itemX - fbWidth - itemDw, bottom - itemY - fbHeight - itemDh, right - itemX - itemDw, bottom - itemY - itemDh); if (!animating) { if (!mOpen) { itemFB.setTranslationY(mMenuButton.getTop() - itemFB.getTop()); itemFB.setTranslationX(mMenuButton.getLeft() - itemFB.getLeft()); itemFB.setVisibility(GONE); } else { itemFB.setTranslationY(0); itemFB.setTranslationX(0); itemFB.setVisibility(VISIBLE); } } } } else { for (int i = 0; i < mMenuItems.size(); i++) { FloatingActionButton item = mMenuItems.get(i); TextView label = mMenuItemLabels.get(i); label.setBackgroundResource(R.drawable.rounded_corners); bottom = top -= mItemGap; top -= item.getMeasuredHeight(); int width = item.getMeasuredWidth(); int d = (mMenuButton.getMeasuredWidth() - width) / 2; item.layout(right - width - d, top, right - d, bottom); d = (item.getMeasuredHeight() - label.getMeasuredHeight()) / 2; label.layout(item.getLeft() - label.getMeasuredWidth() - 50, item.getTop() + d, item.getLeft(), item.getTop() + d + label.getMeasuredHeight()); if (!animating) { if (!mOpen) { item.setTranslationY(mMenuButton.getTop() - item.getTop()); item.setVisibility(GONE); label.setVisibility(GONE); } else { item.setTranslationY(0); item.setVisibility(VISIBLE); label.setVisibility(VISIBLE); } } } } if (!animating && getBackground() != null) { if (!mOpen) { getBackground().setAlpha(0); } else { getBackground().setAlpha(0xff); } } } }
Example 3
Source File: FloatingActionMenu.java From dttv-android with GNU General Public License v3.0 | 4 votes |
/** * Sets the layout of the ViewGroup dependent on the number of menu items as well as menu direction. */ @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { System.out.println("onLayout:" + changed); if (changed) { int right = r - getPaddingRight(); int bottom = b - getPaddingBottom(); int top = bottom - mMenuButton.getMeasuredHeight(); mMenuButton.layout(right - mMenuButton.getMeasuredWidth(), top, right, bottom); int dw = (mMenuButton.getMeasuredWidth() - mIcon.getMeasuredWidth()) / 2; int dh = (mMenuButton.getMeasuredHeight() - mIcon.getMeasuredHeight()) / 2; mIcon.layout(right - mIcon.getMeasuredWidth() - dw, bottom - mIcon.getMeasuredHeight() - dh, right - dw, bottom - dh); if (isCircle) { if (mMenuItems.size() < 2) { Log.e("onLayout", "Floating Action Buttons must more then one!"); return; } double angle = Math.PI/2d/(mMenuItems.size() - 1); for (int i = 0; i < mMenuItems.size(); i++) { FloatingActionButton itemFB = mMenuItems.get(i); int fbWidth = itemFB.getMeasuredWidth(); int fbHeight = itemFB.getMeasuredHeight(); if (0 != multipleOfFB) { mRadius = (int) (fbWidth * multipleOfFB); } int itemDw = (mMenuButton.getMeasuredWidth() - fbWidth) / 2; int itemDh = (mMenuButton.getMeasuredHeight() - fbHeight) / 2; int itemX = (int) (mRadius*Math.cos(i*angle)); int itemY = (int) (mRadius*Math.sin(i*angle)); itemFB.layout(right - itemX - fbWidth - itemDw, bottom - itemY - fbHeight - itemDh, right - itemX - itemDw, bottom - itemY - itemDh); if (!animating) { if (!mOpen) { itemFB.setTranslationY(mMenuButton.getTop() - itemFB.getTop()); itemFB.setTranslationX(mMenuButton.getLeft() - itemFB.getLeft()); itemFB.setVisibility(GONE); } else { itemFB.setTranslationY(0); itemFB.setTranslationX(0); itemFB.setVisibility(VISIBLE); } } } } else { for (int i = 0; i < mMenuItems.size(); i++) { FloatingActionButton item = mMenuItems.get(i); TextView label = mMenuItemLabels.get(i); label.setBackgroundResource(R.drawable.rounded_corners); bottom = top -= mItemGap; top -= item.getMeasuredHeight(); int width = item.getMeasuredWidth(); int d = (mMenuButton.getMeasuredWidth() - width) / 2; item.layout(right - width - d, top, right - d, bottom); d = (item.getMeasuredHeight() - label.getMeasuredHeight()) / 2; label.layout(item.getLeft() - label.getMeasuredWidth() - 50, item.getTop() + d, item.getLeft(), item.getTop() + d + label.getMeasuredHeight()); if (!animating) { if (!mOpen) { item.setTranslationY(mMenuButton.getTop() - item.getTop()); item.setVisibility(GONE); label.setVisibility(GONE); } else { item.setTranslationY(0); item.setVisibility(VISIBLE); label.setVisibility(VISIBLE); } } } } if (!animating && getBackground() != null) { if (!mOpen) { getBackground().setAlpha(0); } else { getBackground().setAlpha(0xff); } } } }