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:com.jakewharton.behavior.drawer.BehaviorDelegate.java

boolean onLayoutChild() {
    int width = parent.getMeasuredWidth();
    int height = parent.getMeasuredHeight();
    int childWidth = child.getMeasuredWidth();
    int childHeight = child.getMeasuredHeight();

    int childLeft;
    float newOffset;
    if (isLeft) {
        childLeft = -childWidth + (int) (childWidth * onScreen);
        newOffset = (float) (childWidth + childLeft) / childWidth;
    } else {/* w w  w.jav  a  2s.c  o m*/
        childLeft = width - (int) (childWidth * onScreen);
        newOffset = (float) (width - childLeft) / childWidth;
    }

    boolean changeOffset = newOffset != onScreen;

    CoordinatorLayout.LayoutParams lp = (CoordinatorLayout.LayoutParams) child.getLayoutParams();
    int vgrav = lp.gravity & Gravity.VERTICAL_GRAVITY_MASK;

    switch (vgrav) {
    default:
    case Gravity.TOP: {
        child.layout(childLeft, lp.topMargin, childLeft + childWidth, lp.topMargin + childHeight);
        break;
    }

    case Gravity.BOTTOM: {
        child.layout(childLeft, height - lp.bottomMargin - child.getMeasuredHeight(), childLeft + childWidth,
                height - lp.bottomMargin);
        break;
    }

    case Gravity.CENTER_VERTICAL: {
        int childTop = (height - childHeight) / 2;

        // Offset for margins. If things don't fit right because of
        // bad measurement before, oh well.
        if (childTop < lp.topMargin) {
            childTop = lp.topMargin;
        } else if (childTop + childHeight > height - lp.bottomMargin) {
            childTop = height - lp.bottomMargin - childHeight;
        }
        child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
        break;
    }
    }

    if (changeOffset) {
        setDrawerViewOffset(newOffset);
    }

    int newVisibility = onScreen > 0 ? VISIBLE : INVISIBLE;
    if (child.getVisibility() != newVisibility) {
        child.setVisibility(newVisibility);
    }
    return true;
}

From source file:com.atomjack.vcfp.VideoControllerView.java

/**
 * Show the controller on screen. It will go away
 * automatically after 'timeout' milliseconds of inactivity.
 * @param timeout The timeout in milliseconds. Use 0 to show
 * the controller until hide() is called.
 *///from w  w w .  j a  v  a2  s. c o m
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.aidy.bottomdrawerlayout.AllDrawerLayout.java

/**
 * Enable or disable interaction with all drawers.
 * /*from  w w  w.  j ava 2  s  . c o  m*/
 * <p>
 * This allows the application to restrict the user's ability to open or
 * close any drawer within this layout. DrawerLayout will still respond to
 * calls to {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends
 * if a drawer is locked.
 * </p>
 * 
 * <p>
 * Locking drawers open or closed will implicitly open or close any drawers
 * as appropriate.
 * </p>
 * 
 * @param lockMode
 *            The new lock mode for the given drawer. One of
 *            {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED}
 *            or {@link #LOCK_MODE_LOCKED_OPEN}.
 */
public void setDrawerLockMode(int lockMode) {
    setDrawerLockMode(lockMode, Gravity.LEFT);
    setDrawerLockMode(lockMode, Gravity.RIGHT);
    setDrawerLockMode(lockMode, Gravity.TOP);
    setDrawerLockMode(lockMode, Gravity.BOTTOM);
}

From source file:com.github.rubensousa.floatingtoolbar.FloatingToolbar.java

@Override
public boolean onLongClick(View v) {
    if (!mMorphed || mMorphing) {
        return false;
    }/*from   w w  w  .  j  av  a2 s  .c  o m*/

    if (mClickListener != null) {
        MenuItem item = (MenuItem) v.getTag();
        if (mShowToast) {
            if (mToast != null) {
                mToast.cancel();
            }
            mToast = Toast.makeText(getContext(), item.getTitle(), Toast.LENGTH_SHORT);
            mToast.setGravity(Gravity.BOTTOM, 0, (int) (getHeight() * 1.25f));
            mToast.show();
        }
        mClickListener.onItemLongClick(item);
        return true;
    } else {
        return false;
    }
}

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

/**
 * Check the lock mode of the given drawer view.
 * //w ww.jav a 2 s .  c  o  m
 * @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.BOTTOM) {
        return mLockModeBottom;
    }
    return LOCK_MODE_UNLOCKED;
}

From source file:com.bookkos.bircle.CaptureActivity.java

@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    _context = getApplicationContext();/*from  www  .  jav  a2s . c o m*/
    _activity = this;

    currentTime = new Time("Asia/Tokyo");

    //      exceptionHandler = new ExceptionHandler(_context);   
    //      Thread.setDefaultUncaughtExceptionHandler(exceptionHandler);

    // sharedPreference???, user_id?group_id?registration_id??
    getUserData();

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    // ??
    WindowManager window_manager = getWindowManager();
    Display display = window_manager.getDefaultDisplay();
    Point point = new Point();
    display.getSize(point);
    displayWidth = point.x;
    displayHeight = point.y;

    displayInch = getInch();
    // ??4???????
    textSize = 17 * (displayInch / 4);

    actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_USE_LOGO);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    String title_text = "";
    subGroupText = "";
    groupText = groupName;

    if (displayInch < 4.7) {
        title_text = "<small><small><small>??: </small></small></small>";
        resizeTitleSizeTooSmall();
    } else if (displayInch >= 4.7 && displayInch < 5.5) {
        title_text = "<small><small>??: </small></small>";
        resizeTitleSizeSmall();
    } else if (displayInch >= 5.5 && displayInch < 6.5) {
        title_text = "<small>??: </small>";
        resizeTitleSizeMiddle();
    } else if (displayInch >= 6.5 && displayInch < 8) {
        title_text = "<small>??: </small>";
        resizeTitleSizeLarge();
    } else {
        title_text = "??: ";
    }
    String modify_group_text = title_text + "<font color=#FF0000>" + groupName + "</font>";
    actionBar.setTitle(Html.fromHtml(modify_group_text));

    Resources resources = _context.getResources();
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    titleBarHeight = resources.getDimensionPixelSize(resourceId);

    setContentView(R.layout.capture);

    returnBorrowHelpView = (ImageView) findViewById(R.id.return_borrow_help_view);
    returnBorrowHelpView.setImageResource(R.drawable.return_borrow_help);
    returnBorrowHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    returnBorrowHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));

    registHelpView = (ImageView) findViewById(R.id.regist_help_view);
    registHelpView.setImageResource(R.drawable.regist_help);
    registHelpView.setTranslationY(displayHeight / 5 + titleBarHeight);
    registHelpView.setLayoutParams(new FrameLayout.LayoutParams(displayWidth,
            displayHeight / 5 + titleBarHeight, Gravity.BOTTOM | Gravity.CENTER));
    registHelpView.setVisibility(View.GONE);

    leftDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    leftDrawer = (ListView) findViewById(R.id.left_drawer);
    textView = (TextView) findViewById(R.id.textView);

    modeText = (TextView) findViewById(R.id.mode_text);
    modeText.setTextColor(Color.rgb(56, 234, 123));
    modeText.setTextSize(textSize);
    modeText.setTypeface(Typeface.SERIF.MONOSPACE, Typeface.BOLD);
    strokeColor = Color.rgb(56, 234, 123);

    borrowReturnButton = (Button) findViewById(R.id.borrowReturnButton);
    registButton = (Button) findViewById(R.id.registButton);
    returnHistoryButton = (Button) findViewById(R.id.return_history_button);
    helpViewButton = (Button) findViewById(R.id.help_view_button);

    registSelectShelfRelativeLayout = (RelativeLayout) findViewById(R.id.regist_select_shelf_relative_layout);
    textViewLinearLayout = (LinearLayout) findViewById(R.id.text_view_linear_layout);
    buttonLinearLayout = (LinearLayout) findViewById(R.id.button_linear_layout);
    listViewLinearLayout = (LinearLayout) findViewById(R.id.list_view_linear_layout);
    decisionButton = (Button) findViewById(R.id.decision_button);
    cancelButton = (Button) findViewById(R.id.cancel_button);
    shelfListView = (ListView) findViewById(R.id.shelf_list_view);
    tempTextView = (TextView) findViewById(R.id.temp_text_view);
    //      bookListViewAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1);
    bookListViewAdapter = new BookListViewAdapter(_context, R.layout.book_list_row, this);

    bookRegistRelativeLayout = (RelativeLayout) findViewById(R.id.book_regist_relative_layout);
    bookRegistLinearLayout = (LinearLayout) findViewById(R.id.book_regist_linear_layout);
    bookRegistListViewLinearLayout = (LinearLayout) findViewById(R.id.book_regist_list_view_linear_layout);
    bookRegistListView = (ListView) findViewById(R.id.book_regist_list_view);
    bookRegistTextView = (TextView) findViewById(R.id.book_regist_text_view);
    bookRegistCancelButton = (Button) findViewById(R.id.book_regist_cancel_button);

    registFlag = 0;

    int borrowReturnButton_width = displayWidth / 5 * 2;
    int borrowReturnButton_height = displayHeight / 10;
    int borrowReturnButton_x = ((displayWidth / 2) - borrowReturnButton_width) / 2;
    int borrowReturnButton_y = displayHeight / 2 + titleBarHeight;
    borrowReturnButton.setTranslationX(borrowReturnButton_x);
    borrowReturnButton.setTranslationY(borrowReturnButton_y);
    borrowReturnButton
            .setLayoutParams(new FrameLayout.LayoutParams(borrowReturnButton_width, borrowReturnButton_height));
    borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));
    borrowReturnButton.setText("??\n");
    borrowReturnButton.setTextSize(textSize * 7 / 10);
    borrowReturnButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 0;

            borrowReturnButton.setText("??\n");
            borrowReturnButton.setEnabled(false);
            borrowReturnButton.setTextColor(Color.WHITE);
            borrowReturnButton.setBackgroundColor(Color.rgb(56, 234, 123));

            registButton.setText("?\n??");
            registButton.setEnabled(true);
            registButton.setTextColor(Color.GRAY);
            registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));

            modeText.setText("??");
            modeText.setTextColor(Color.rgb(56, 234, 123));
            returnBorrowHelpView.setVisibility(View.VISIBLE);
            registHelpView.setVisibility(View.GONE);
            strokeColor = Color.rgb(56, 234, 123);
        }
    });

    int registButton_width = displayWidth / 5 * 2;
    int registButton_height = displayHeight / 10;
    int registButton_x = (displayWidth / 2) + ((displayWidth / 2) - registButton_width) / 2;
    int registButton_y = displayHeight / 2 + titleBarHeight;
    registButton.setTranslationX(registButton_x);
    registButton.setTranslationY(registButton_y);
    registButton.setLayoutParams(new FrameLayout.LayoutParams(registButton_width, registButton_height));
    registButton.setBackgroundColor(Color.argb(170, 21, 38, 45));
    registButton.setTextColor(Color.GRAY);
    registButton.setTextSize(textSize * 7 / 10);
    registButton.setText("?\n??");
    registButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            arrayList.clear();
            registFlag = 1;

            borrowReturnButton.setText("??\n??");
            borrowReturnButton.setEnabled(true);
            borrowReturnButton.setTextColor(Color.GRAY);
            borrowReturnButton.setBackgroundColor(Color.argb(170, 9, 54, 16));

            registButton.setText("?\n");
            registButton.setEnabled(false);
            registButton.setTextColor(Color.WHITE);
            registButton.setBackgroundColor(Color.rgb(62, 162, 229));

            modeText.setText("?");
            modeText.setTextColor(Color.rgb(62, 162, 229));
            returnBorrowHelpView.setVisibility(View.GONE);
            registHelpView.setVisibility(View.VISIBLE);
            strokeColor = Color.rgb(62, 162, 229);
        }
    });

    returnHistoryButton.setText("????");
    returnHistoryButton.setTextSize(textSize * 7 / 10);
    returnHistoryButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            leftDrawerLayout.openDrawer(Gravity.RIGHT);
            //            animateTranslationY(bookRegistRelativeLayout, displayHeight, displayHeight - displayHeight / 4 - titleBarHeight);
        }
    });
    getReturnHistory();
    getCurrentTime();

    setHelpView();
    setScanUnregisterBookView();
    setBookRegistView();

    arrayList = new ArrayList<String>();
    tempRegistIsbn = "";

    initBookRegistUrl = book_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initLendRegistUrl = lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initTemporaryLendRegistUrl = temporary_lend_register_url + "?user_id=" + userId + "&group_id=" + groupId;
    initCatalogRegistUrl = catalog_register_url + "?group_id=" + groupId + "&book_code=";
    initManuallyCatalogRegistUrl = manually_catalog_register_url + "?group_id=" + groupId + "&book_code=";
    getStatusUrl = get_status_url + "?group_id=" + groupId + "&user_id=" + userId;

    hasSurface = false;

    inactivityTimer = new InactivityTimer(this);
    bircleBeepManager = new BircleBeepManager(this);
    ambientLightManager = new AmbientLightManager(this);

    PreferenceManager.setDefaultValues(this, R.xml.preferences, false);

    toastText = "";
}

From source file:com.example.verticaldrawerlayout.VerticalDrawerLayout.java

/**
 * Enable or disable interaction with the given drawer.
 * /*from  w w w . j a v a 2 s.c  om*/
 * <p>
 * This allows the application to restrict the user's ability to open or
 * close the given drawer. DrawerLayout will still respond to calls to
 * {@link #openDrawer(int)}, {@link #closeDrawer(int)} and friends if a
 * drawer is locked.
 * </p>
 * 
 * <p>
 * Locking a drawer open or closed will implicitly open or close that drawer
 * as appropriate.
 * </p>
 * 
 * @param lockMode
 *            The new lock mode for the given drawer. One of
 *            {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED}
 *            or {@link #LOCK_MODE_LOCKED_OPEN}.
 * @param edgeGravity
 *            Gravity.LEFT, RIGHT, START or END.
 *            Expresses which drawer to change the mode for.
 * 
 * @see #LOCK_MODE_UNLOCKED
 * @see #LOCK_MODE_LOCKED_CLOSED
 * @see #LOCK_MODE_LOCKED_OPEN
 */
public void setDrawerLockMode(int lockMode, int edgeGravity) {
    final int absGravity = GravityCompat.getAbsoluteGravity(edgeGravity, ViewCompat.getLayoutDirection(this));
    if (absGravity == Gravity.TOP) {
        mLockModeTop = lockMode;
    } else if (absGravity == Gravity.BOTTOM) {
        mLockModeBottom = lockMode;
    }
    if (lockMode != LOCK_MODE_UNLOCKED) {
        // Cancel interaction in progress
        final ViewDragHelper helper = absGravity == Gravity.TOP ? mTopDragger : mBottomDragger;
        helper.cancel();
    }
    switch (lockMode) {
    case LOCK_MODE_LOCKED_OPEN:
        final View toOpen = findDrawerWithGravity(absGravity);
        if (toOpen != null) {
            openDrawer(toOpen);
        }
        break;
    case LOCK_MODE_LOCKED_CLOSED:
        final View toClose = findDrawerWithGravity(absGravity);
        if (toClose != null) {
            closeDrawer(toClose);
        }
        break;
    // default: do nothing
    }
}

From source file:com.alirezaafkar.toolbar.ToolbarWidgetWrapper.java

@Override
public void setEmbeddedTabView(ScrollingTabContainerView tabView) {
    if (mTabView != null && mTabView.getParent() == mToolbar) {
        mToolbar.removeView(mTabView);//www .  ja  va 2 s . co  m
    }
    mTabView = tabView;
    if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mToolbar.addView(mTabView, 0);
        RtlToolbar.LayoutParams lp = (RtlToolbar.LayoutParams) mTabView.getLayoutParams();
        lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.START | Gravity.BOTTOM;
        tabView.setAllowCollapse(true);
    }
}

From source file:ca.nehil.rter.streamingapp.StreamingActivity.java

private void initLayout() {
    /* get size of screen */
    Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/* ww w.  j  a  va2  s  . co m*/
    //size of screen
    screenWidth = size.x;
    screenHeight = size.y;

    FrameLayout.LayoutParams layoutParam = null;
    LayoutInflater myInflate = null;
    myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    topLayout = new FrameLayout(this);
    setContentView(topLayout);

    mGLView = overlay.getGLView(); // OpenGLview
    int display_width_d = (int) (1.0 * screenWidth);
    int display_height_d = (int) (1.0 * screenHeight);
    int button_width = 0;
    int button_height = 0;
    int prev_rw, prev_rh;

    if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) {
        prev_rh = display_height_d;
        button_height = display_height_d;
        prev_rw = (int) (1.0 * display_height_d * live_width / live_height);
        button_width = display_width_d - prev_rw;

    } else {
        prev_rw = display_width_d;
        prev_rh = (int) (1.0 * display_width_d * live_height / live_width);
    }

    layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM);

    Log.d("LAYOUT",
            "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:"
                    + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:"
                    + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height);

    Log.d("CameraDebug", "InitLayout acquired camera");

    if (CAMERA_PREVIEW) {
        cameraDevice = openCamera();
        cameraView = new CameraView(this, cameraDevice);

        topLayout.addView(cameraView, layoutParam);
    }

    layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER);

    topLayout.addView(mGLView, layoutParam);

    FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null);
    layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight);
    topLayout.addView(preViewLayout, layoutParam);
    Log.i(LOG_TAG, "cameara preview start: OK");
}

From source file:android.support.v7.internal.widget.ToolbarWidgetWrapper.java

@Override
public void setEmbeddedTabView(ScrollingTabContainerView tabView) {
    if (mTabView != null && mTabView.getParent() == mToolbar) {
        mToolbar.removeView(mTabView);/*from  w w  w  .ja  v  a 2 s  .com*/
    }
    mTabView = tabView;
    if (tabView != null && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
        mToolbar.addView(mTabView, 0);
        Toolbar.LayoutParams lp = (Toolbar.LayoutParams) mTabView.getLayoutParams();
        lp.width = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
        lp.gravity = Gravity.START | Gravity.BOTTOM;
        tabView.setAllowCollapse(true);
    }
}