Example usage for android.view Gravity BOTTOM

List of usage examples for android.view Gravity BOTTOM

Introduction

In this page you can find the example usage for android.view Gravity BOTTOM.

Prototype

int BOTTOM

To view the source code for android.view Gravity BOTTOM.

Click Source Link

Document

Push object to the bottom of its container, not changing its size.

Usage

From source file:android.support.v7.internal.view.menu.ActionMenuItemView.java

@Override
public boolean onLongClick(View v) {
    if (hasText()) {
        // Don't show the cheat sheet for items that already show text.
        return false;
    }/*from  www  .jav  a2s . c om*/

    final int[] screenPos = new int[2];
    final Rect displayFrame = new Rect();
    getLocationOnScreen(screenPos);
    getWindowVisibleDisplayFrame(displayFrame);

    final Context context = getContext();
    final int width = getWidth();
    final int height = getHeight();
    final int midy = screenPos[1] + height / 2;
    int referenceX = screenPos[0] + width / 2;
    if (ViewCompat.getLayoutDirection(v) == ViewCompat.LAYOUT_DIRECTION_LTR) {
        final int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
        referenceX = screenWidth - referenceX; // mirror
    }
    Toast cheatSheet = Toast.makeText(context, mItemData.getTitle(), Toast.LENGTH_SHORT);
    if (midy < displayFrame.height()) {
        // Show along the top; follow action buttons
        cheatSheet.setGravity(Gravity.TOP | GravityCompat.END, referenceX, height);
    } else {
        // Show along the bottom center
        cheatSheet.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, height);
    }
    cheatSheet.show();
    return true;
}

From source file:android.support.wear.widget.drawer.WearableDrawerView.java

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();

    // The peek view has a layout gravity of bottom for the top drawer, and a layout gravity
    // of top for the bottom drawer. This is required so that the peek view shows. On the top
    // drawer, the bottom peeks from the top, and on the bottom drawer, the top peeks.
    // LayoutParams are not guaranteed to return a non-null value until a child is attached to
    // the window.
    LayoutParams peekParams = (LayoutParams) mPeekContainer.getLayoutParams();
    if (!Gravity.isVertical(peekParams.gravity)) {
        final boolean isTopDrawer = (((LayoutParams) getLayoutParams()).gravity
                & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.TOP;
        if (isTopDrawer) {
            peekParams.gravity = Gravity.BOTTOM;
            mPeekIcon.setImageResource(R.drawable.ws_ic_more_horiz_24dp_wht);
        } else {/*from www  . jav a  2s.  c om*/
            peekParams.gravity = Gravity.TOP;
            mPeekIcon.setImageResource(R.drawable.ws_ic_more_vert_24dp_wht);
        }
        mPeekContainer.setLayoutParams(peekParams);
    }
}

From source file:com.moods_final.moods.entertainment.VideoListDemoActivity.java

/**
 * Sets up the layout programatically for the three different states. Portrait, landscape or
 * fullscreen+landscape. This has to be done programmatically because we handle the orientation
 * changes ourselves in order to get fluent fullscreen transitions, so the xml layout resources
 * do not get reloaded.//w  w w.j  av a 2s.  c  om
 */
private void layout() {
    boolean isPortrait = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;

    listFragment.getView().setVisibility(isFullscreen ? View.GONE : View.VISIBLE);
    listFragment.setLabelVisibility(isPortrait);
    closeButton.setVisibility(isPortrait ? View.VISIBLE : View.GONE);

    if (isFullscreen) {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, MATCH_PARENT, Gravity.TOP | Gravity.LEFT);
    } else if (isPortrait) {
        setLayoutSize(listFragment.getView(), MATCH_PARENT, MATCH_PARENT);
        setLayoutSize(videoFragment.getView(), MATCH_PARENT, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, MATCH_PARENT, WRAP_CONTENT, Gravity.BOTTOM);
    } else {
        videoBox.setTranslationY(0); // Reset any translation that was applied in portrait.
        int screenWidth = dpToPx(getResources().getConfiguration().screenWidthDp);
        setLayoutSize(listFragment.getView(), screenWidth / 4, MATCH_PARENT);
        int videoWidth = screenWidth - screenWidth / 4 - dpToPx(LANDSCAPE_VIDEO_PADDING_DP);
        setLayoutSize(videoFragment.getView(), videoWidth, WRAP_CONTENT);
        setLayoutSizeAndGravity(videoBox, videoWidth, WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL);
    }
}

From source file:com.example.mapsample.view.ActionSheet.java

private View createView() {
    FrameLayout parent = new FrameLayout(getActivity());
    parent.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg = new View(getActivity());
    mBg.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT));
    mBg.setBackgroundColor(Color.argb(136, 0, 0, 0));
    mBg.setId(ActionSheet.BG_VIEW_ID);/* ww  w  . j a  v a 2 s  . c  o  m*/
    mBg.setOnClickListener(this);

    mPanel = new LinearLayout(getActivity());
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT);
    params.gravity = Gravity.BOTTOM;
    mPanel.setLayoutParams(params);
    mPanel.setOrientation(LinearLayout.VERTICAL);
    parent.setPadding(0, 0, 0, getNavBarHeight(getActivity()));
    parent.addView(mBg);
    parent.addView(mPanel);
    return parent;
}

From source file:es.curso.android.streamingVLC.VideoActivity.java

/*************
 * Player//from w w  w.  j  ava 2  s  . c o m
 *************/

private void createPlayer(String media) {
    releasePlayer();

    if (media.length() > 0) {
        Toast toast = Toast.makeText(this, media, Toast.LENGTH_LONG);
        toast.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
        toast.show();
    }

    // Create a new media player
    try {
        libvlc = LibVLC.getInstance();
    } catch (LibVlcException e) {
        Toast.makeText(this, "Can't create player", Toast.LENGTH_LONG).show();
        return;
    }
    libvlc.setIomx(false);
    libvlc.setSubtitlesEncoding("");
    libvlc.setAout(LibVLC.AOUT_OPENSLES);
    libvlc.setTimeStretching(true);
    libvlc.setChroma("RV32");
    libvlc.setVerboseMode(true);
    LibVLC.restart(this);
    EventHandler.getInstance().addHandler(mHandler);
    if (holder == null)
        Log.d(TAG, "holder==null");
    holder.setFormat(PixelFormat.RGBX_8888);
    holder.setKeepScreenOn(true);
    MediaList list = libvlc.getMediaList();
    list.clear();
    list.add(new Media(libvlc, LibVLC.PathToURI(media)), false);
    libvlc.playIndex(0);

}

From source file:ca.mymenuapp.ui.widgets.SlidingUpPanelLayout.java

public SlidingUpPanelLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    if (attrs != null) {
        TypedArray defAttrs = context.obtainStyledAttributes(attrs, DEFAULT_ATTRS);

        if (defAttrs != null) {
            int gravity = defAttrs.getInt(0, Gravity.NO_GRAVITY);
            if (gravity != Gravity.TOP && gravity != Gravity.BOTTOM) {
                throw new IllegalArgumentException("layout_gravity must be set to either top or bottom");
            }// w ww  . j  a  v  a  2 s . c  o  m
            mIsSlidingUp = gravity == Gravity.BOTTOM;
        }

        defAttrs.recycle();

        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SlidingUpPanelLayout);

        if (ta != null) {
            mPanelHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_collapsedHeight, -1);
            mShadowHeight = ta.getDimensionPixelSize(R.styleable.SlidingUpPanelLayout_shadowHeight, -1);

            mMinFlingVelocity = ta.getInt(R.styleable.SlidingUpPanelLayout_flingVelocity,
                    DEFAULT_MIN_FLING_VELOCITY);
            mCoveredFadeColor = ta.getColor(R.styleable.SlidingUpPanelLayout_fadeColor, DEFAULT_FADE_COLOR);

            mDragViewResId = ta.getResourceId(R.styleable.SlidingUpPanelLayout_dragView, -1);
        }

        ta.recycle();
    }

    final float density = context.getResources().getDisplayMetrics().density;
    if (mPanelHeight == -1) {
        mPanelHeight = (int) (DEFAULT_PANEL_HEIGHT * density + 0.5f);
    }
    if (mShadowHeight == -1) {
        mShadowHeight = (int) (DEFAULT_SHADOW_HEIGHT * density + 0.5f);
    }

    setWillNotDraw(false);

    mDragHelper = ViewDragHelper.create(this, 0.5f, new DragHelperCallback());
    mDragHelper.setMinVelocity(mMinFlingVelocity * density);

    mCanSlide = true;
    mIsSlidingEnabled = true;

    ViewConfiguration vc = ViewConfiguration.get(context);
    mScrollTouchSlop = vc.getScaledTouchSlop();
}

From source file:com.farmerbb.taskbar.service.TaskbarService.java

@SuppressLint("RtlHardcoded")
private void drawTaskbar() {
    IconCache.getInstance(this).clearCache();

    // Initialize layout params
    windowManager = (WindowManager) getSystemService(WINDOW_SERVICE);
    U.setCachedRotation(windowManager.getDefaultDisplay().getRotation());

    final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.TYPE_PHONE,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM,
            PixelFormat.TRANSLUCENT);//from   w ww. j  av  a  2s . com

    // Determine where to show the taskbar on screen
    switch (U.getTaskbarPosition(this)) {
    case "bottom_left":
        layoutId = R.layout.taskbar_left;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        positionIsVertical = false;
        break;
    case "bottom_vertical_left":
        layoutId = R.layout.taskbar_vertical;
        params.gravity = Gravity.BOTTOM | Gravity.LEFT;
        positionIsVertical = true;
        break;
    case "bottom_right":
        layoutId = R.layout.taskbar_right;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        positionIsVertical = false;
        break;
    case "bottom_vertical_right":
        layoutId = R.layout.taskbar_vertical;
        params.gravity = Gravity.BOTTOM | Gravity.RIGHT;
        positionIsVertical = true;
        break;
    case "top_left":
        layoutId = R.layout.taskbar_left;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        positionIsVertical = false;
        break;
    case "top_vertical_left":
        layoutId = R.layout.taskbar_top_vertical;
        params.gravity = Gravity.TOP | Gravity.LEFT;
        positionIsVertical = true;
        break;
    case "top_right":
        layoutId = R.layout.taskbar_right;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        positionIsVertical = false;
        break;
    case "top_vertical_right":
        layoutId = R.layout.taskbar_top_vertical;
        params.gravity = Gravity.TOP | Gravity.RIGHT;
        positionIsVertical = true;
        break;
    }

    // Initialize views
    int theme = 0;

    SharedPreferences pref = U.getSharedPreferences(this);
    switch (pref.getString("theme", "light")) {
    case "light":
        theme = R.style.AppTheme;
        break;
    case "dark":
        theme = R.style.AppTheme_Dark;
        break;
    }

    boolean altButtonConfig = pref.getBoolean("alt_button_config", false);

    ContextThemeWrapper wrapper = new ContextThemeWrapper(this, theme);
    layout = (LinearLayout) LayoutInflater.from(wrapper).inflate(layoutId, null);
    taskbar = (LinearLayout) layout.findViewById(R.id.taskbar);
    scrollView = (FrameLayout) layout.findViewById(R.id.taskbar_scrollview);

    if (altButtonConfig) {
        space = (Space) layout.findViewById(R.id.space_alt);
        layout.findViewById(R.id.space).setVisibility(View.GONE);
    } else {
        space = (Space) layout.findViewById(R.id.space);
        layout.findViewById(R.id.space_alt).setVisibility(View.GONE);
    }

    space.setOnClickListener(v -> toggleTaskbar());

    startButton = (ImageView) layout.findViewById(R.id.start_button);
    int padding;

    if (pref.getBoolean("app_drawer_icon", false)) {
        startButton.setImageDrawable(ContextCompat.getDrawable(this, R.mipmap.ic_launcher));
        padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding_alt);
    } else {
        startButton.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.all_apps_button_icon));
        padding = getResources().getDimensionPixelSize(R.dimen.app_drawer_icon_padding);
    }

    startButton.setPadding(padding, padding, padding, padding);
    startButton.setOnClickListener(ocl);
    startButton.setOnLongClickListener(view -> {
        openContextMenu();
        return true;
    });

    startButton.setOnGenericMotionListener((view, motionEvent) -> {
        if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY)
            openContextMenu();

        return false;
    });

    refreshInterval = (int) (Float.parseFloat(pref.getString("refresh_frequency", "2")) * 1000);
    if (refreshInterval == 0)
        refreshInterval = 100;

    sortOrder = pref.getString("sort_order", "false");
    runningAppsOnly = pref.getString("recents_amount", "past_day").equals("running_apps_only");

    switch (pref.getString("recents_amount", "past_day")) {
    case "past_day":
        searchInterval = System.currentTimeMillis() - AlarmManager.INTERVAL_DAY;
        break;
    case "app_start":
        long oneDayAgo = System.currentTimeMillis() - AlarmManager.INTERVAL_DAY;
        long appStartTime = pref.getLong("time_of_service_start", System.currentTimeMillis());
        long deviceStartTime = System.currentTimeMillis() - SystemClock.elapsedRealtime();
        long startTime = deviceStartTime > appStartTime ? deviceStartTime : appStartTime;

        searchInterval = startTime > oneDayAgo ? startTime : oneDayAgo;
        break;
    }

    Intent intent = new Intent("com.farmerbb.taskbar.HIDE_START_MENU");
    LocalBroadcastManager.getInstance(TaskbarService.this).sendBroadcast(intent);

    if (altButtonConfig) {
        button = (Button) layout.findViewById(R.id.hide_taskbar_button_alt);
        layout.findViewById(R.id.hide_taskbar_button).setVisibility(View.GONE);
    } else {
        button = (Button) layout.findViewById(R.id.hide_taskbar_button);
        layout.findViewById(R.id.hide_taskbar_button_alt).setVisibility(View.GONE);
    }

    try {
        button.setTypeface(Typeface.createFromFile("/system/fonts/Roboto-Regular.ttf"));
    } catch (RuntimeException e) {
        /* Gracefully fail */ }

    updateButton(false);
    button.setOnClickListener(v -> toggleTaskbar());

    LinearLayout buttonLayout = (LinearLayout) layout.findViewById(
            altButtonConfig ? R.id.hide_taskbar_button_layout_alt : R.id.hide_taskbar_button_layout);
    if (buttonLayout != null)
        buttonLayout.setOnClickListener(v -> toggleTaskbar());

    LinearLayout buttonLayoutToHide = (LinearLayout) layout.findViewById(
            altButtonConfig ? R.id.hide_taskbar_button_layout : R.id.hide_taskbar_button_layout_alt);
    if (buttonLayoutToHide != null)
        buttonLayoutToHide.setVisibility(View.GONE);

    int backgroundTint = U.getBackgroundTint(this);
    int accentColor = U.getAccentColor(this);

    dashboardButton = (FrameLayout) layout.findViewById(R.id.dashboard_button);
    navbarButtons = (LinearLayout) layout.findViewById(R.id.navbar_buttons);

    dashboardEnabled = pref.getBoolean("dashboard", false);
    if (dashboardEnabled) {
        layout.findViewById(R.id.square1).setBackgroundColor(accentColor);
        layout.findViewById(R.id.square2).setBackgroundColor(accentColor);
        layout.findViewById(R.id.square3).setBackgroundColor(accentColor);
        layout.findViewById(R.id.square4).setBackgroundColor(accentColor);
        layout.findViewById(R.id.square5).setBackgroundColor(accentColor);
        layout.findViewById(R.id.square6).setBackgroundColor(accentColor);

        dashboardButton.setOnClickListener(v -> LocalBroadcastManager.getInstance(TaskbarService.this)
                .sendBroadcast(new Intent("com.farmerbb.taskbar.TOGGLE_DASHBOARD")));
    } else
        dashboardButton.setVisibility(View.GONE);

    if (pref.getBoolean("button_back", false)) {
        navbarButtonsEnabled = true;

        ImageView backButton = (ImageView) layout.findViewById(R.id.button_back);
        backButton.setVisibility(View.VISIBLE);
        backButton.setOnClickListener(v -> {
            U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_BACK);
            if (pref.getBoolean("hide_taskbar", true)
                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                hideTaskbar(true);
        });
    }

    if (pref.getBoolean("button_home", false)) {
        navbarButtonsEnabled = true;

        ImageView homeButton = (ImageView) layout.findViewById(R.id.button_home);
        homeButton.setVisibility(View.VISIBLE);
        homeButton.setOnClickListener(v -> {
            U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_HOME);
            if (pref.getBoolean("hide_taskbar", true)
                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                hideTaskbar(true);
        });

        homeButton.setOnLongClickListener(v -> {
            Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
            voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

            try {
                startActivity(voiceSearchIntent);
            } catch (ActivityNotFoundException e) {
                /* Gracefully fail */ }

            if (pref.getBoolean("hide_taskbar", true)
                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                hideTaskbar(true);

            return true;
        });

        homeButton.setOnGenericMotionListener((view13, motionEvent) -> {
            if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                    && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                Intent voiceSearchIntent = new Intent(RecognizerIntent.ACTION_VOICE_SEARCH_HANDS_FREE);
                voiceSearchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                try {
                    startActivity(voiceSearchIntent);
                } catch (ActivityNotFoundException e) {
                    /* Gracefully fail */ }

                if (pref.getBoolean("hide_taskbar", true)
                        && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                    hideTaskbar(true);
            }
            return true;
        });
    }

    if (pref.getBoolean("button_recents", false)) {
        navbarButtonsEnabled = true;

        ImageView recentsButton = (ImageView) layout.findViewById(R.id.button_recents);
        recentsButton.setVisibility(View.VISIBLE);
        recentsButton.setOnClickListener(v -> {
            U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_RECENTS);
            if (pref.getBoolean("hide_taskbar", true)
                    && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                hideTaskbar(true);
        });

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            recentsButton.setOnLongClickListener(v -> {
                U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN);
                if (pref.getBoolean("hide_taskbar", true)
                        && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                    hideTaskbar(true);

                return true;
            });

            recentsButton.setOnGenericMotionListener((view13, motionEvent) -> {
                if (motionEvent.getAction() == MotionEvent.ACTION_BUTTON_PRESS
                        && motionEvent.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                    U.sendAccessibilityAction(this, AccessibilityService.GLOBAL_ACTION_TOGGLE_SPLIT_SCREEN);
                    if (pref.getBoolean("hide_taskbar", true)
                            && !FreeformHackHelper.getInstance().isInFreeformWorkspace())
                        hideTaskbar(true);
                }
                return true;
            });
        }
    }

    if (!navbarButtonsEnabled)
        navbarButtons.setVisibility(View.GONE);

    layout.setBackgroundColor(backgroundTint);
    layout.findViewById(R.id.divider).setBackgroundColor(accentColor);
    button.setTextColor(accentColor);

    if (isFirstStart && FreeformHackHelper.getInstance().isInFreeformWorkspace())
        showTaskbar(false);
    else if (!pref.getBoolean("collapsed", false) && pref.getBoolean("taskbar_active", false))
        toggleTaskbar();

    LocalBroadcastManager.getInstance(this).unregisterReceiver(showReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(hideReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(tempShowReceiver);
    LocalBroadcastManager.getInstance(this).unregisterReceiver(tempHideReceiver);

    LocalBroadcastManager.getInstance(this).registerReceiver(showReceiver,
            new IntentFilter("com.farmerbb.taskbar.SHOW_TASKBAR"));
    LocalBroadcastManager.getInstance(this).registerReceiver(hideReceiver,
            new IntentFilter("com.farmerbb.taskbar.HIDE_TASKBAR"));
    LocalBroadcastManager.getInstance(this).registerReceiver(tempShowReceiver,
            new IntentFilter("com.farmerbb.taskbar.TEMP_SHOW_TASKBAR"));
    LocalBroadcastManager.getInstance(this).registerReceiver(tempHideReceiver,
            new IntentFilter("com.farmerbb.taskbar.TEMP_HIDE_TASKBAR"));

    startRefreshingRecents();

    windowManager.addView(layout, params);

    isFirstStart = false;
}

From source file:com.tiancaicc.springfloatingactionmenu.SpringFloatingActionMenu.java

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    super.onLayout(changed, left, top, right, bottom);

    Resources resources = getResources();
    Activity context = (Activity) mContext;

    // layout FAB and follow circles
    int fabWidth = mFAB.getMeasuredWidth();
    int fabHeight = mFAB.getMeasuredHeight();
    int bottomInsets = Utils.getInsetsBottom(context, this);

    int fabX = 0;
    int fabY = 0;
    if (mGravity == (Gravity.BOTTOM | Gravity.RIGHT)) {
        int marginX = Utils.dpToPx(mMarginSize, resources);
        int marginY = Utils.dpToPx(mMarginSize, resources) + bottomInsets;
        fabX = right - fabWidth - marginX;
        fabY = bottom - fabHeight - marginY;
        mFAB.layout(fabX, fabY, fabX + fabWidth, fabY + fabHeight);
    } else if (mGravity == (Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM)) {
        int marginY = Utils.dpToPx(mMarginSize, resources) + bottomInsets;
        fabX = right / 2 - fabWidth / 2;
        fabY = bottom - fabHeight - marginY;
        mFAB.layout(fabX, fabY, fabX + fabWidth, fabY + fabHeight);
    } else {/*from   w w  w. ja  v a  2 s  . c o m*/
        throw new IllegalStateException("gravity only support bottom center and bottom right");
    }

    int fabCenterX = fabX + fabWidth / 2;
    int fabCenterY = fabY + fabHeight / 2;

    for (ImageButton circle : mFollowCircles) {
        int x = fabCenterX - circle.getWidth() / 2;
        int y = fabCenterY - circle.getHeight() / 2;
        circle.layout(x, y, x + circle.getMeasuredWidth(), y + circle.getMeasuredHeight());
    }

    int x = fabCenterX - mRevealCircle.getWidth() / 2;
    int y = fabCenterY - mRevealCircle.getHeight() / 2;
    mRevealCircle.layout(x, y, x + mRevealCircle.getMeasuredWidth(), y + mRevealCircle.getMeasuredHeight());

    //layout menu items
    layoutMenuItems(left, top, right, bottom);
}

From source file:com.aidy.bottomdrawerlayout.BottomDrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow. The drawable
 * provided must have a nonzero intrinsic width.
 * /*from   w w w .j  a v a2 s  .c  o m*/
 * @param shadowDrawable
 *            Shadow drawable to use at the edge of a drawer
 * @param gravity
 *            Which drawer the shadow should apply to
 */
public void setDrawerShadow(Drawable shadowDrawable, int gravity) {

    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
    if ((absGravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
        mShadowBottom = shadowDrawable;
        invalidate();
    }
}

From source file:com.alburivan.slickform.tooltip.SimpleTooltip.java

private PointF calculePopupLocation() {
    PointF location = new PointF();

    final RectF anchorRect = SimpleTooltipUtils.calculeRectInWindow(mAnchorView);
    final PointF anchorCenter = new PointF(anchorRect.centerX(), anchorRect.centerY());

    switch (mGravity) {
    case Gravity.START:
        location.x = anchorRect.left - mPopupWindow.getContentView().getWidth() - mMargin;
        location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f;
        break;//  www .  j  a va 2  s  . com
    case Gravity.END:
        location.x = anchorRect.right + mMargin;
        location.y = anchorCenter.y - mPopupWindow.getContentView().getHeight() / 2f;
        break;
    case Gravity.TOP:
        location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f;
        location.y = anchorRect.top - mPopupWindow.getContentView().getHeight() - mMargin;
        break;
    case Gravity.BOTTOM:
        location.x = anchorCenter.x - mPopupWindow.getContentView().getWidth() / 2f;
        location.y = anchorRect.bottom + mMargin;
        break;
    default:
        throw new IllegalArgumentException("Gravity must have be START, END, TOP or BOTTOM.");
    }

    return location;
}