List of usage examples for android.view Gravity BOTTOM
int BOTTOM
To view the source code for android.view Gravity BOTTOM.
Click Source Link
From source file:ch.luklanis.esscan.history.HistoryActivity.java
@Override public boolean handleMessage(Message message) { int msgId = 0; switch (message.what) { case R.id.history_menu_send_dta_email: { Uri dtaFileUri = (Uri) message.obj; if (dtaFileUri != null) { try { startActivity(createMailIntent(dtaFileUri)); return true; } catch (Exception ex) { msgId = R.string.msg_no_email_client; }//from w w w .ja v a 2 s . c o m } } break; case R.id.history_menu_send_dta_other: { Uri dtaFileUri = (Uri) message.obj; if (dtaFileUri != null) { startActivity(Intent.createChooser(createShareIntent(dtaFileUri), "Send with...")); return true; } } break; case R.id.history_menu_send_dta_save: break; case R.id.es_send_succeeded: { mSendingProgressDialog.dismiss(); HistoryItem historyItem = historyFragment.getHistoryItemOnPosition(message.arg1); if (historyItem != null) { String filename = getResources().getString(R.string.history_item_sent); historyItem.update(new HistoryItem.Builder(historyItem).setDtaFile(filename).create()); mHistoryManager.updateHistoryItemFileName(historyItem.getItemId(), filename); //historyFragment.updatePosition(message.arg1, historyItem); historyFragment.dataChanged(); PsDetailFragment fragment = (PsDetailFragment) getFragmentManager() .findFragmentById(R.id.ps_detail_container); if (fragment != null) { fragment.getHistoryItem().update(historyItem); fragment.updateDtaFilename(fragment.getView()); } } msgId = R.string.msg_coderow_sent; } break; case R.id.es_send_failed: mSendingProgressDialog.dismiss(); msgId = R.string.msg_coderow_not_sent; break; } if (msgId != 0) { Toast toast = Toast.makeText(getApplicationContext(), msgId, Toast.LENGTH_SHORT); toast.setGravity(Gravity.BOTTOM, 0, 0); toast.show(); return true; } return false; }
From source file:com.jet.sweettips.snackbar.SweetSnackbar.java
final void showView() { if (mView.getParent() == null) { final ViewGroup.LayoutParams lp = mView.getLayoutParams(); if (lp instanceof CoordinatorLayout.LayoutParams) { // If our LayoutParams are from a CoordinatorLayout, we'll setup our Behavior final CoordinatorLayout.LayoutParams clp = (CoordinatorLayout.LayoutParams) lp; final Behavior behavior = new Behavior(); behavior.setStartAlphaSwipeDistance(0.1f); behavior.setEndAlphaSwipeDistance(0.6f); behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END); behavior.setListener(new SwipeDismissBehavior.OnDismissListener() { @Override/* www . j a v a2 s . com*/ public void onDismiss(View view) { view.setVisibility(View.GONE); dispatchDismiss(Callback.DISMISS_EVENT_SWIPE); } @Override public void onDragStateChanged(int state) { switch (state) { case SwipeDismissBehavior.STATE_DRAGGING: case SwipeDismissBehavior.STATE_SETTLING: // If the view is being dragged or settling, cancel the timeout SweetSnackbarManager.getInstance().cancelTimeout(mManagerCallback); break; case SwipeDismissBehavior.STATE_IDLE: // If the view has been released and is idle, restore the timeout SweetSnackbarManager.getInstance().restoreTimeout(mManagerCallback); break; } } }); clp.setBehavior(behavior); // Also set the inset edge so that views can dodge the snackbar correctly clp.insetEdge = Gravity.BOTTOM; } mTargetParent.addView(mView); } mView.setOnAttachStateChangeListener(new SnackbarLayout.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { } @Override public void onViewDetachedFromWindow(View v) { if (isShownOrQueued()) { // If we haven't already been dismissed then this event is coming from a // non-user initiated action. Hence we need to make sure that we callback // and keep our state up to date. We need to post the call since removeView() // will call through to onDetachedFromWindow and thus overflow. sHandler.post(new Runnable() { @Override public void run() { onViewHidden(Callback.DISMISS_EVENT_MANUAL); } }); } } }); if (ViewCompat.isLaidOut(mView)) { if (shouldAnimate()) { // If animations are enabled, animate it in animateViewIn(); } else { // Else if anims are disabled just call back now onViewShown(); } } else { // Otherwise, add one of our layout change listeners and show it in when laid out mView.setOnLayoutChangeListener(new SnackbarLayout.OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom) { mView.setOnLayoutChangeListener(null); if (shouldAnimate()) { // If animations are enabled, animate it in animateViewIn(); } else { // Else if anims are disabled just call back now onViewShown(); } } }); } }
From source file:com.lcl.designsnackbar.tsnackbar.TSnackbar.java
final void showView() { if (mView.getParent() == null) { final ViewGroup.LayoutParams lp = mView.getLayoutParams(); if (lp instanceof CoordinatorLayout.LayoutParams) { // If our LayoutParams are from a CoordinatorLayout, we'll setup our Behavior final CoordinatorLayout.LayoutParams clp = (CoordinatorLayout.LayoutParams) lp; final Behavior behavior = new Behavior(); behavior.setStartAlphaSwipeDistance(0.1f); behavior.setEndAlphaSwipeDistance(0.6f); behavior.setSwipeDirection(SwipeDismissBehavior.SWIPE_DIRECTION_START_TO_END); behavior.setListener(new SwipeDismissBehavior.OnDismissListener() { @Override//from w w w. j a va 2 s . c o m public void onDismiss(View view) { view.setVisibility(View.GONE); dispatchDismiss(Callback.DISMISS_EVENT_SWIPE); } @Override public void onDragStateChanged(int state) { switch (state) { case SwipeDismissBehavior.STATE_DRAGGING: case SwipeDismissBehavior.STATE_SETTLING: // If the view is being dragged or settling, cancel the timeout SnackbarManager.getInstance().cancelTimeout(mManagerCallback); break; case SwipeDismissBehavior.STATE_IDLE: // If the view has been released and is idle, restore the timeout SnackbarManager.getInstance().restoreTimeout(mManagerCallback); break; } } }); clp.setBehavior(behavior); // Also set the inset edge so that views can dodge the snackbar correctly clp.insetEdge = Gravity.BOTTOM; } mTargetParent.addView(mView); } mView.setOnAttachStateChangeListener(new SnackbarLayout.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { } @Override public void onViewDetachedFromWindow(View v) { if (isShownOrQueued()) { // If we haven't already been dismissed then this event is coming from a // non-user initiated action. Hence we need to make sure that we callback // and keep our state up to date. We need to post the call since removeView() // will call through to onDetachedFromWindow and thus overflow. sHandler.post(new Runnable() { @Override public void run() { onViewHidden(Callback.DISMISS_EVENT_MANUAL); } }); } } }); if (ViewCompat.isLaidOut(mView)) { if (shouldAnimate()) { // If animations are enabled, animate it in animateViewIn(); } else { // Else if anims are disabled just call back now onViewShown(); } } else { // Otherwise, add one of our layout change listeners and show it in when laid out mView.setOnLayoutChangeListener(new SnackbarLayout.OnLayoutChangeListener() { @Override public void onLayoutChange(View view, int left, int top, int right, int bottom) { mView.setOnLayoutChangeListener(null); if (shouldAnimate()) { // If animations are enabled, animate it in animateViewIn(); } else { // Else if anims are disabled just call back now onViewShown(); } } }); } }
From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java
/** * Check the lock mode of the drawer with the given gravity. * //from ww w. j av a 2s. co m * @param edgeGravity * Gravity of the drawer to check * @return one of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. */ public int getDrawerLockMode(int edgeGravity) { final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this)); if (absGravity == Gravity.TOP) { return mLockModeTop; } else if (absGravity == Gravity.BOTTOM) { return mLockModeBottom; } return LOCK_MODE_UNLOCKED; }
From source file:android.support.wear.widget.drawer.WearableDrawerLayout.java
/** * Peek the drawer./* w w w . j ava 2s .co m*/ * * @param gravity {@link Gravity#TOP} to peek the top drawer or {@link Gravity#BOTTOM} to peek * the bottom drawer. */ void peekDrawer(final int gravity) { if (!isLaidOut()) { // If this view is not laid out yet, postpone the peek until onLayout is called. if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "WearableDrawerLayout not laid out yet. Postponing peek."); } switch (gravity) { case Gravity.TOP: mShouldPeekTopDrawerAfterLayout = true; break; case Gravity.BOTTOM: mShouldPeekBottomDrawerAfterLayout = true; break; default: // fall out } return; } final WearableDrawerView drawerView = findDrawerWithGravity(gravity); maybePeekDrawer(drawerView); }
From source file:com.taobao.weex.extend.module.actionsheet.WXActionSheet.java
private View createRoot() { FrameLayout parent = new FrameLayout(getActivity()); parent.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); backgroundLayer = new View(getActivity()); backgroundLayer.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); backgroundLayer.setBackgroundColor(Color.argb(136, 0, 0, 0)); backgroundLayer.setOnClickListener(new View.OnClickListener() { @Override/*www. j av a2s. c om*/ public void onClick(View v) { dismiss(); if (actionListener != null) { actionListener.onCancel(); } } }); sheetContainer = new LinearLayout(getActivity()); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.BOTTOM; sheetContainer.setLayoutParams(params); sheetContainer.setOrientation(LinearLayout.VERTICAL); sheetContainer.setPadding(dp2px(8), dp2px(8), dp2px(8), dp2px(8)); parent.setPadding(0, 0, 0, getNavBarHeight(getActivity())); parent.addView(backgroundLayer); parent.addView(sheetContainer); return parent; }
From source file:com.mobilevue.vod.VideoControllerView.java
/** * Show the controller on screen. It will go away automatically after * 'timeout' milliseconds of inactivity. * //from w w w . ja v a2 s . co m * @param timeout * The timeout in milliseconds. Use 0 to show the controller * until hide() is called. */ public void show(int timeout) { if (!mShowing && mAnchor != null) { setProgress(); if (mPauseButton != null) { mPauseButton.requestFocus(); } disableUnsupportedButtons(); FrameLayout.LayoutParams tlp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.BOTTOM); mAnchor.addView(this, tlp); mShowing = true; } updatePausePlay(); // updateFullScreen(); // cause the progress bar to be updated even if mShowing // was already true. This happens, for example, if we're // paused with the progress bar showing the user hits play. mHandler.sendEmptyMessage(SHOW_PROGRESS); Message msg = mHandler.obtainMessage(FADE_OUT); if (timeout != 0) { mHandler.removeMessages(FADE_OUT); mHandler.sendMessageDelayed(msg, timeout); } }
From source file:com.google.blockly.android.ToolboxFragment.java
/** * Updates the padding used to calculate the margins of the scrollable blocks, based on the size * and placement of the tabs./*from w ww .j a v a 2 s. c o m*/ */ private void updateScrollablePadding() { int buttonHeight = mActionButton.getVisibility() == View.GONE ? 0 : mActionButton.getMeasuredHeight(); int buttonWidth = mActionButton.getVisibility() == View.GONE ? 0 : mActionButton.getMeasuredWidth(); int buttonVerticalPadding = 0, buttonHorizontalPadding = 0; if (mScrollOrientation == SCROLL_VERTICAL) { buttonVerticalPadding = buttonHeight; } else { buttonHorizontalPadding = buttonWidth; } int layoutDir = ViewCompat.getLayoutDirection(mRootView); int spacingForTabs; switch (GravityCompat.getAbsoluteGravity(mTabEdge, layoutDir)) { case Gravity.LEFT: spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredWidth() : 0; // Horizontal mScrollablePadding.set(spacingForTabs + buttonHorizontalPadding, buttonVerticalPadding, 0, 0); break; case Gravity.TOP: spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredHeight() : 0; // Vertical if (layoutDir == ViewCompat.LAYOUT_DIRECTION_LTR) { mScrollablePadding.set(buttonHorizontalPadding, spacingForTabs + buttonVerticalPadding, 0, 0); } else { mScrollablePadding.set(0, spacingForTabs + buttonVerticalPadding, buttonHorizontalPadding, 0); } break; case Gravity.RIGHT: spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredWidth() : 0; // Horizontal mScrollablePadding.set(0, buttonVerticalPadding, spacingForTabs + buttonHorizontalPadding, 0); break; case Gravity.BOTTOM: spacingForTabs = hasTabs() ? mCategoryTabs.getMeasuredHeight() : 0; // Vertical if (layoutDir == ViewCompat.LAYOUT_DIRECTION_LTR) { mScrollablePadding.set(buttonHorizontalPadding, 0, 0, spacingForTabs + buttonVerticalPadding); } else { mScrollablePadding.set(0, 0, buttonHorizontalPadding, spacingForTabs + buttonVerticalPadding); } break; } }
From source file:com.doubleTwist.drawerlib.ADrawerLayout.java
protected void layoutView(View v, int l, int t, int r, int b) { LayoutParams params = (LayoutParams) v.getLayoutParams(); Rect bounds = new Rect(); Rect boundsWithoutPeek = new Rect(); int gravity = params.gravity; switch (gravity) { case Gravity.RIGHT: if (DEBUG) Log.d(TAG, "gravity: right"); bounds.left = r - v.getMeasuredWidth() - mPeekSize.right; bounds.top = t;//from www.j a v a2 s . c o m bounds.right = r - mPeekSize.right; bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(mPeekSize.right, 0); mMinScrollX = -bounds.width(); break; case Gravity.TOP: if (DEBUG) Log.d(TAG, "gravity: top"); bounds.left = l; bounds.top = t + mPeekSize.top; bounds.right = v.getMeasuredWidth(); bounds.bottom = t + v.getMeasuredHeight() + mPeekSize.top; v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(0, -mPeekSize.top); mMaxScrollY = bounds.height(); break; case Gravity.BOTTOM: if (DEBUG) Log.d(TAG, "gravity: bottom"); bounds.left = l; bounds.top = b - v.getMeasuredHeight() - mPeekSize.bottom; bounds.right = l + v.getMeasuredWidth(); bounds.bottom = b - mPeekSize.bottom; v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(0, mPeekSize.bottom); mMinScrollY = -bounds.height(); break; case Gravity.LEFT: if (DEBUG) Log.d(TAG, "gravity: left"); bounds.left = l + mPeekSize.left; bounds.top = t; bounds.right = l + v.getMeasuredWidth() + mPeekSize.left; bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); mMaxScrollX = bounds.width(); boundsWithoutPeek = new Rect(bounds); boundsWithoutPeek.offset(-mPeekSize.left, 0); break; default: if (DEBUG) Log.d(TAG, "gravity: default"); bounds.left = l; bounds.top = t; bounds.right = l + v.getMeasuredWidth(); bounds.bottom = t + v.getMeasuredHeight(); v.layout(bounds.left, bounds.top, bounds.right, bounds.bottom); boundsWithoutPeek = new Rect(bounds); break; } if (DEBUG) { Log.d(TAG, " == VIEW LAYOUT == " + v.toString()); Log.d(TAG, "bounds: " + bounds.left + "," + bounds.top + "," + bounds.right + "," + bounds.bottom); } if (mLayoutBounds.containsKey(v)) mLayoutBounds.remove(v); mLayoutBounds.put(v, bounds); if (mLayoutBoundsWithoutPeek.containsKey(v)) mLayoutBoundsWithoutPeek.remove(v); mLayoutBoundsWithoutPeek.put(v, boundsWithoutPeek); }
From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java
/** * Check the lock mode of the given drawer view. * /* ww w . j a v a 2s. c om*/ * @param drawerView * Drawer view to check lock mode * @return one of {@link #LOCK_MODE_UNLOCKED}, * {@link #LOCK_MODE_LOCKED_CLOSED} or * {@link #LOCK_MODE_LOCKED_OPEN}. */ public int getDrawerLockMode(View drawerView) { final int absGravity = getDrawerViewAbsoluteGravity(drawerView); if (absGravity == Gravity.TOP) { return mLockModeTop; } else if (absGravity == Gravity.BOTTOM) { return mLockModeBottom; } return LOCK_MODE_UNLOCKED; }