Example usage for android.view Gravity START

List of usage examples for android.view Gravity START

Introduction

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

Prototype

int START

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

Click Source Link

Document

Push object to x-axis position at the start of its container, not changing its size.

Usage

From source file:fr.paug.droidcon.ui.BaseActivity.java

/**
 * Sets up the navigation drawer as appropriate. Note that the nav drawer will be
 * different depending on whether the attendee indicated that they are attending the
 * event on-site vs. attending remotely.
 *//*from w  ww .  j  ava2  s  .c o m*/
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }
    if (selfItem == NAVDRAWER_ITEM_INVALID) {
        // do not show a nav drawer
        View navDrawer = mDrawerLayout.findViewById(R.id.navdrawer);
        if (navDrawer != null) {
            ((ViewGroup) navDrawer.getParent()).removeView(navDrawer);
        }
        mDrawerLayout = null;
        return;
    }

    mDrawerToggle = mLPreviewUtils.setupDrawerToggle(mDrawerLayout, new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            // run deferred action, if we have one
            if (mDeferredOnDrawerClosedRunnable != null) {
                mDeferredOnDrawerClosedRunnable.run();
                mDeferredOnDrawerClosedRunnable = null;
            }
            if (mAccountBoxExpanded) {
                mAccountBoxExpanded = false;
                setupAccountBoxToggle();
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            updateStatusBarForNavDrawerSlide(0f);
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            updateStatusBarForNavDrawerSlide(1f);
            onNavDrawerStateChanged(true, false);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            invalidateOptionsMenu();
            onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            updateStatusBarForNavDrawerSlide(slideOffset);
            onNavDrawerSlide(slideOffset);
        }
    });
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    getActionBar().setDisplayHomeAsUpEnabled(true);
    getActionBar().setHomeButtonEnabled(true);

    // populate the nav drawer with the correct items
    populateNavDrawer();

    mDrawerToggle.syncState();

    // When the user runs the app for the first time, we want to land them with the
    // navigation drawer open. But just the first time.
    if (!PrefUtils.isWelcomeDone(this)) {
        // first run of the app starts with the nav drawer open
        PrefUtils.markWelcomeDone(this);
        mDrawerLayout.openDrawer(Gravity.START);
    }
}

From source file:com.qa.perf.emmageeplus.service.EmmageeService.java

/**
 * create a floating window to show real-time data.
 *//* ww w . ja  v a  2  s.  c o m*/
private void createFloatingWindow() {
    getSharedPreferences("float_flag", Activity.MODE_PRIVATE).edit().putInt("float", 1).apply();
    windowManager = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    wmParams = ((MyApplication) getApplication()).getMywmParams();
    wmParams.type = WindowManager.LayoutParams.TYPE_PHONE;
    wmParams.flags |= 8;
    wmParams.gravity = Gravity.START | Gravity.TOP;
    wmParams.x = 0;
    wmParams.y = 0;
    wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT;
    wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
    wmParams.format = 1;
    windowManager.addView(viFloatingWindow, wmParams);
    viFloatingWindow.setOnTouchListener(new OnTouchListener() {
        public boolean onTouch(View v, MotionEvent event) {
            x = event.getRawX();
            y = event.getRawY() - statusBarHeight;
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                mTouchStartX = event.getX();
                mTouchStartY = event.getY();
                break;
            case MotionEvent.ACTION_MOVE:
                updateViewPosition();
                break;
            case MotionEvent.ACTION_UP:
                updateViewPosition();
                mTouchStartX = mTouchStartY = 0;
                break;
            }
            return true;
        }
    });

    btnWifi.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            try {
                btnWifi = (Button) viFloatingWindow.findViewById(R.id.wifi);
                String buttonText = (String) btnWifi.getText();
                String wifiText = getResources().getString(R.string.open_wifi);
                if (buttonText.equals(wifiText)) {
                    wifiManager.setWifiEnabled(true);
                    btnWifi.setText(R.string.close_wifi);
                } else {
                    wifiManager.setWifiEnabled(false);
                    btnWifi.setText(R.string.open_wifi);
                }
            } catch (Exception e) {
                Toast.makeText(viFloatingWindow.getContext(), getString(R.string.wifi_fail_toast),
                        Toast.LENGTH_LONG).show();
                Log.e(LOG_TAG, e.toString());
            }
        }
    });
}

From source file:ca.zadrox.dota2esportticker.ui.BaseActivity.java

private void onNavDrawerItemClicked(final int itemId) {
    if (itemId == getSelfNavDrawerItem()) {
        mDrawerLayout.closeDrawer(Gravity.START);
        return;//from   w  w w.ja  v a 2 s.  c  om
    }

    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            goToNavDrawerItem(itemId);
        }
    }, NAVDRAWER_LAUNCH_DELAY);

    setSelectedNavDrawerItem(itemId);

    View mainContent = findViewById(R.id.main_content);
    if (mainContent != null) {
        //mainContent.animate().alpha(0).setDuration(MAIN_CONTENT_FADEOUT_DURATION);
    }

    mDrawerLayout.closeDrawer(Gravity.START);
}

From source file:cz.metaverse.android.bilingualreader.ReaderActivity.java

/**
 * Called when the user presses the Back key.
 *///from   w ww.  jav  a 2s  .  c o m
@Override
public void onBackPressed() {
    // If the navigation drawer is opened, close it.
    if (navigationDrawerLayout.isDrawerOpen(Gravity.START)) {
        navigationDrawerLayout.closeDrawer(Gravity.START);
    }
    // See if there is some PanelViewState.notes or PanelViewState.metadata panel to be closed,
    // if so, close it. If not, moveTaskToBack().
    else if (!governor.closeLastOpenedNotes()) {
        moveTaskToBack(true);
    }
}

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

@Override
public void setEmbeddedTabView(ScrollingTabContainerView tabView) {
    if (mTabView != null && mTabView.getParent() == mToolbar) {
        mToolbar.removeView(mTabView);/*from   w  w  w  .j  a va 2s  . c om*/
    }
    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:com.sonaive.v2ex.ui.BaseActivity.java

/**
 * Sets up the navigation drawer as appropriate. Note that the nav drawer will be
 * different depending on whether the attendee indicated that they are attending the
 * event on-site vs. attending remotely.
 *//*from www .  j  a v a2  s  .  c o m*/
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    ScrollView navContent = (ScrollView) findViewById(R.id.navdrawer);
    if (mDrawerLayout == null || navContent == null) {
        return;
    }
    FrameLayout mainContent = (FrameLayout) findViewById(R.id.main_content);

    // set static navigation drawer
    if (mainContent != null
            && ((ViewGroup.MarginLayoutParams) mainContent.getLayoutParams()).leftMargin == (int) getResources()
                    .getDimension(R.dimen.navdrawer_width)) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, navContent);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
    }

    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.theme_primary_dark));
    ScrimInsetsScrollView navDrawer = (ScrimInsetsScrollView) mDrawerLayout.findViewById(R.id.navdrawer);
    if (selfItem == NAVDRAWER_ITEM_INVALID) {
        // do not show a nav drawer
        if (navDrawer != null) {
            ((ViewGroup) navDrawer.getParent()).removeView(navDrawer);
        }
        mDrawerLayout = null;
        return;
    }

    if (navDrawer != null) {
        final View chosenAccountContentView = findViewById(R.id.chosen_account_content_view);
        final View chosenAccountView = findViewById(R.id.chosen_account_view);
        final int navDrawerChosenAccountHeight = getResources()
                .getDimensionPixelSize(R.dimen.navdrawer_chosen_account_height);
        navDrawer.setOnInsetsCallback(new ScrimInsetsScrollView.OnInsetsCallback() {
            @Override
            public void onInsetsChanged(Rect insets) {
                ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) chosenAccountContentView
                        .getLayoutParams();
                lp.topMargin = insets.top;
                chosenAccountContentView.setLayoutParams(lp);

                ViewGroup.LayoutParams lp2 = chosenAccountView.getLayoutParams();
                lp2.height = navDrawerChosenAccountHeight + insets.top;
                chosenAccountView.setLayoutParams(lp2);
            }
        });
    }

    if (mActionBarToolbar != null) {
        mActionBarToolbar.setNavigationIcon(R.drawable.ic_drawer);
        mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(Gravity.START);
            }
        });
    }

    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            // run deferred action, if we have one
            if (mDeferredOnDrawerClosedRunnable != null) {
                mDeferredOnDrawerClosedRunnable.run();
                mDeferredOnDrawerClosedRunnable = null;
            }
            if (mAccountBoxExpanded) {
                mAccountBoxExpanded = false;
                setupAccountBoxToggle();
            }
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            onNavDrawerStateChanged(true, false);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            onNavDrawerSlide(slideOffset);
        }
    });

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    // populate the nav drawer with the correct items
    populateNavDrawer();
}

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  www . jav a  2s.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);
    }
}

From source file:com.mumu.pokemongogo.HeadService.java

private void initGameControlButtons() {
    mDirectionIconList = new ArrayList<>();

    // Up button// ww  w.ja  v  a 2  s . com
    HeadIconView upButton = new HeadIconView(new ImageView(this), mWindowManager, 130, 160);
    upButton.getImageView().setImageResource(R.drawable.ic_arrow_up);
    upButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    upButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.NORTH, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(upButton);

    // Down button
    HeadIconView downButton = new HeadIconView(new ImageView(this), mWindowManager, 130, 0);
    downButton.getImageView().setImageResource(R.drawable.ic_arrow_down);
    downButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    downButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.SOUTH, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(downButton);

    // Left button
    HeadIconView leftButton = new HeadIconView(new ImageView(this), mWindowManager, 50, 80);
    leftButton.getImageView().setImageResource(R.drawable.ic_arrow_left);
    leftButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    leftButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.WEST, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(leftButton);

    // Right button
    HeadIconView rightButton = new HeadIconView(new ImageView(this), mWindowManager, 210, 80);
    rightButton.getImageView().setImageResource(R.drawable.ic_arrow_right);
    rightButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    rightButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.EAST, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(rightButton);

    // North West button
    HeadIconView upLeftButton = new HeadIconView(new ImageView(this), mWindowManager, 50, 160);
    upLeftButton.getImageView().setImageResource(R.drawable.ic_arrow_squart);
    upLeftButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    upLeftButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.NORTHWEST, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(upLeftButton);

    // West South button
    HeadIconView leftDownButton = new HeadIconView(new ImageView(this), mWindowManager, 50, 0);
    leftDownButton.getImageView().setImageResource(R.drawable.ic_arrow_squart);
    leftDownButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    leftDownButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.WESTSOUTH, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(leftDownButton);

    // South East button
    HeadIconView downRightButton = new HeadIconView(new ImageView(this), mWindowManager, 210, 0);
    downRightButton.getImageView().setImageResource(R.drawable.ic_arrow_squart);
    downRightButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    downRightButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.SOUTHEAST, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(downRightButton);

    // East North button
    HeadIconView rightUpButton = new HeadIconView(new ImageView(this), mWindowManager, 210, 160);
    rightUpButton.getImageView().setImageResource(R.drawable.ic_arrow_squart);
    rightUpButton.getImageView()
            .setBackgroundColor(ContextCompat.getColor(mContext, R.color.button_half_transparent));
    rightUpButton.setOnTapListener(new HeadIconView.OnTapListener() {
        @Override
        public void onTap(View view) {
            mFakeLocationManager.setSpeed(mWalkSpeed);
            mFakeLocationManager.walkPace(FakeLocation.EASTNORTH, 1.0);
        }

        @Override
        public void onLongPress(View view) {

        }
    });
    mDirectionIconList.add(rightUpButton);

    // add view and set invisible
    for (HeadIconView icon : mDirectionIconList) {
        icon.setVisibility(View.INVISIBLE);
        icon.setGravity(Gravity.BOTTOM | Gravity.START, false);
        icon.addView();
    }
}

From source file:com.offers.couponempire.ui.BaseActivity.java

/**
 * Sets up the navigation drawer as appropriate. Note that the nav drawer will be
 * different depending on whether the attendee indicated that they are attending the
 * event on-site vs. attending remotely.
 *//*from w w  w .  j  a v  a 2s  .  co m*/
private void setupNavDrawer() {
    // What nav drawer item should be selected?
    int selfItem = getSelfNavDrawerItem();

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;
    }

    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.primary_dark));

    if (selfItem == NAVDRAWER_ITEM_INVALID) {
        // do not show a nav drawer
        View navDrawer = mDrawerLayout.findViewById(R.id.navdrawer);
        if (navDrawer != null) {
            ((ViewGroup) navDrawer.getParent()).removeView(navDrawer);
        }
        mDrawerLayout = null;
        return;
    }

    if (mActionBarToolbar != null) {
        mActionBarToolbar.setNavigationIcon(R.drawable.ic_navigation_drawer);
        mActionBarToolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mDrawerLayout.openDrawer(Gravity.START);
            }
        });
    }

    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerClosed(View drawerView) {
            // run deferred action, if we have one
            if (mDeferredOnDrawerClosedRunnable != null) {
                mDeferredOnDrawerClosedRunnable.run();
                mDeferredOnDrawerClosedRunnable = null;
            }
            //invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            //updateStatusBarForNavDrawerSlide(0f);
            onNavDrawerStateChanged(false, false);
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            //invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
            //updateStatusBarForNavDrawerSlide(1f);
            onNavDrawerStateChanged(true, false);
        }

        @Override
        public void onDrawerStateChanged(int newState) {
            //invalidateOptionsMenu();
            onNavDrawerStateChanged(isNavDrawerOpen(), newState != DrawerLayout.STATE_IDLE);
        }

        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            //updateStatusBarForNavDrawerSlide(slideOffset);
            onNavDrawerSlide(slideOffset);
        }
    });

    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    //getActionBar().setDisplayHomeAsUpEnabled(true);
    //getActionBar().setHomeButtonEnabled(true);

    // populate the nav drawer with the correct items
    populateNavDrawer();

    // When the user runs the app for the first time, we want to land them with the
    // navigation drawer open. But just the first time.
    if (!PrefUtils.isWelcomeDone(this)) {
        // first run of the app starts with the nav drawer open
        PrefUtils.markWelcomeDone(this);
        mDrawerLayout.openDrawer(Gravity.START);
    }
}

From source file:fr.shywim.antoinedaniel.ui.MainActivity.java

private void setupNavDrawer() {
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    if (mDrawerLayout == null) {
        return;//w w w . ja  va 2  s .c om
    }

    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.primary));
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);

    setupNavDrawerButton();

    populateNavDrawer();
}