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:com.ushahidi.android.ui.activity.BaseActivity.java

protected void createNavDrawer() {
    if (mDrawerLayoutId != 0) {
        mDrawerLayout = (DrawerLayout) findViewById(mDrawerLayoutId);
    }/* w  ww .  j  ava 2s  .  c om*/

    if (mDrawerLayout == null) {
        return;
    }

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

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mActionBarToolbar, R.string.open,
            R.string.close);

    mDrawerLayout.setDrawerListener(mDrawerToggle);

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

    mDrawerLayout.setDrawerListener(new DrawerLayout.DrawerListener() {
        @Override
        public void onDrawerSlide(View drawerView, float slideOffset) {
            onNavDrawerSlide(slideOffset);
        }

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

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

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

    createNavDrawerItems();
}

From source file:com.doomy.library.Internal.PopupIndicator.java

private WindowManager.LayoutParams createPopupLayout(IBinder token) {
    WindowManager.LayoutParams p = new WindowManager.LayoutParams();
    p.gravity = Gravity.START | Gravity.TOP;
    p.width = ViewGroup.LayoutParams.MATCH_PARENT;
    p.height = ViewGroup.LayoutParams.MATCH_PARENT;
    p.format = PixelFormat.TRANSLUCENT;/*from  www  .  j  a  va  2  s  .  c  o  m*/
    p.flags = computeFlags(p.flags);
    p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL;
    p.token = token;
    p.softInputMode = WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN;
    p.setTitle("DiscreteSeekBar Indicator:" + Integer.toHexString(hashCode()));

    return p;
}

From source file:org.borderstone.tagtags.TTProtocolActivity.java

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

    this.setContentView(R.layout.activity_protocol);

    this.setTheme(R.style.AppTheme);

    if (Constants.files.contains(Constants.filename)) {
        int idex = Constants.files.indexOf(Constants.filename);
        row = Constants.file_rows.get(idex);
    }/*from www.ja v a2 s.  c  o m*/

    lblGlobal = new BTitleLabel(this);
    lblLocal = new BTitleLabel(this);
    btnUpload = new BButton(this);

    lblGlobal.setPadding(15, 15, 15, 15);
    lblLocal.setPadding(15, 15, 15, 15);
    lblGlobal.setGravity(Gravity.CENTER);
    lblLocal.setGravity(Gravity.CENTER);
    lblLocal.setTextColor(Color.WHITE);
    lblGlobal.setTextColor(Color.WHITE);
    lblLocal.setTextSize(Constants.fontSize + 2);
    lblGlobal.setTextSize(Constants.fontSize + 2);

    lblGlobal.setText("GLOBAL PROPERTIES");
    lblLocal.setText("TECHNICAL MATERIAL");

    widgetLayout = new BMultiColumnLayout(this);
    mDrawerList = (LinearLayout) this.findViewById(R.id.protocolDrawer);

    lockSwitch = new Switch(this);

    btnUpload.setOnClickListener(this);

    btnUpload.setIcon(R.drawable.upload);
    btnUpload.setText("Upload data");

    btnGPS = new ImageButton(this);

    btnGPS.setOnClickListener(this);
    btnGPS.setLongClickable(true);
    btnGPS.setOnLongClickListener(this);

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    DrawerLayout.LayoutParams lp = new DrawerLayout.LayoutParams(metrics.densityDpi * 2,
            LinearLayout.LayoutParams.MATCH_PARENT);
    lp.gravity = Gravity.START;

    sv = (ScrollView) this.findViewById(R.id.protocolBack);

    widgetLayout.setLayoutParams(Constants.defaultParams);

    sv.addView(widgetLayout);
    sv.setLayoutTransition(new LayoutTransition());

    toolbar = (Toolbar) this.findViewById(R.id.protToolbar);
    this.setSupportActionBar(toolbar);

    toolbar.setNavigationIcon(R.drawable.drawer);

    toolbar.inflateMenu(R.menu.protocol_menu);

    toolbar.addView(lockSwitch);

    lblPercent = new BTitleLabel(this);
    lblInfo = new BInfoLabel(this);

    drawProtocolPage();

    widgetLayout.setFocusable(true);
    widgetLayout.setFocusableInTouchMode(true);
    widgetLayout.requestFocus();

    mDrawerList.bringToFront();

    final DrawerLayout drawerLayout = (DrawerLayout) this.findViewById(R.id.drawerLayoutProtocol);
    toolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (!drawerLayout.isDrawerOpen(Gravity.LEFT))
                drawerLayout.openDrawer(Gravity.LEFT);
            else
                drawerLayout.closeDrawer(Gravity.LEFT);
        }
    });
}

From source file:com.ephemeraldreams.gallyshuttle.ui.MainActivity.java

/**
 * Close drawers smoothly with no stutters.
 *
 * @param runnable Runnable to run after drawer closed.
 *///from   www  . ja  v  a  2  s  .c  o  m
private void closeDrawers(Runnable runnable) {
    if (drawerLayout.isDrawerOpen(Gravity.START)) {
        drawerLayout.closeDrawers();
        drawerHandler.removeCallbacksAndMessages(null);
        drawerHandler.postDelayed(runnable, 250);
        drawerLayout.closeDrawers();
    }
}

From source file:app.hanks.com.conquer.activity.MainActivity.java

/**
 * ???/*from   w  w w.j  a va  2s  .  c  om*/
 */
public void toggle() {
    if (drawerLayout.isDrawerOpen(Gravity.START)) {
        drawerLayout.closeDrawer(Gravity.START);
        //            materialMenu.animatePressedState(MaterialMenuDrawable.IconState.BURGER);
    } else {
        //            materialMenu.animatePressedState(MaterialMenuDrawable.IconState.X);
        drawerLayout.openDrawer(Gravity.START);
    }
}

From source file:com.rodrigopontes.androidbubbles.BubblesManager.java

/**
 * Adds new Bubble to BubblesManager/*from www.j ava 2s .  co m*/
 */
public void addBubble(Bubble bubble) {
    if (windowManager != null) {
        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_LAYOUT_NO_LIMITS,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.TOP | Gravity.START;
        params.y = screenHeight / BubblesProperties.BUBBLE_ENTER_Y_POSITION;
        BubbleController bubbleController = new BubbleController(bubble, params);
        bubble.getFrameLayout().setOnTouchListener(bubbleController.new BubbleTouchListener());
        bubblesList.add(bubbleController);
        windowManager.addView(bubble.getFrameLayout(), params);
        bubbleController.createdAnimation = new SpringAnimation(
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION,
                        screenWidth + BubblesProperties.BUBBLE_ENTER_SPEED),
                new AnimationPosition(BubblesProperties.MODE_STATIC_POSITION, screenWidth
                        - (int) (bubbleController.bubbleWidth * BubblesProperties.BUBBLE_EDGE_OFFSET_RIGHT)),
                params, BubblesProperties.AXIS_X, BubblesProperties.SPRING_ANIMATION_LONG_DURATION, bubble)
                        .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    } else {
        throw new NullPointerException("BubblesManager has not yet been created! Use .create() first.");
    }
}

From source file:android.support.transition.SidePropagation.java

private int getMaxDistance(ViewGroup sceneRoot) {
    switch (mSide) {
    case Gravity.LEFT:
    case Gravity.RIGHT:
    case Gravity.START:
    case Gravity.END:
        return sceneRoot.getWidth();
    default://from   w  w w .j  a v  a  2s.c om
        return sceneRoot.getHeight();
    }
}

From source file:com.justplay1.shoppist.shared.base.adapters.BaseGroupSwipeableItemAdapter.java

@Override
public void onSetChildItemSwipeBackground(CVH holder, int groupPosition, int childPosition, int type) {
    int bgResId = R.drawable.bg_swipe_item_neutral;
    LayerDrawable drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
    switch (type) {
    case SwipeableItemConstants.DRAWABLE_SWIPE_LEFT_BACKGROUND:
        switch (getLeftSwipeActionType()) {
        case SwipeActionType.MOVE_ITEM:
            if (getChildItem(groupPosition, childPosition).getStatus()) {
                bgResId = getMoveToStatusNotDoneIcon();
            } else {
                bgResId = getMoveToStatusDoneIcon();
            }/* www .  j  av a2 s  .c  o  m*/
            break;
        case SwipeActionType.DELETE_ITEM:
            bgResId = R.drawable.bg_swipe_item_delete_action;
            break;
        case SwipeActionType.EDIT_ITEM:
            bgResId = R.drawable.bg_swipe_item_edit_action;
            break;
        }
        drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
        ((BitmapDrawable) drawable.findDrawableByLayerId(R.id.image))
                .setGravity(Gravity.END | Gravity.CENTER_VERTICAL);
        break;
    case SwipeableItemConstants.DRAWABLE_SWIPE_RIGHT_BACKGROUND:
        bgResId = R.drawable.bg_swipe_item_move_to_cart_action;
        switch (getRightSwipeActionType()) {
        case SwipeActionType.MOVE_ITEM:
            if (getChildItem(groupPosition, childPosition).getStatus()) {
                bgResId = getMoveToStatusNotDoneIcon();
            } else {
                bgResId = getMoveToStatusDoneIcon();
            }
            break;
        case SwipeActionType.DELETE_ITEM:
            bgResId = R.drawable.bg_swipe_item_delete_action;
            break;
        case SwipeActionType.EDIT_ITEM:
            bgResId = R.drawable.bg_swipe_item_edit_action;
            break;
        }
        drawable = (LayerDrawable) ContextCompat.getDrawable(context, bgResId);
        ((BitmapDrawable) drawable.findDrawableByLayerId(R.id.image))
                .setGravity(Gravity.START | Gravity.CENTER_VERTICAL);
        break;
    }
    DrawableUtils.setViewDrawable(holder.itemView, drawable);
}

From source file:com.bradbergeron.splitviewcontrollerdemo.activities.MainActivity.java

public void setNavigationDrawerEnabled(final boolean enabled) {
    mDrawerToggle.setDrawerIndicatorEnabled(enabled);

    if (enabled) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.START);
    } else {/*  w w w  . j a va  2  s . c  o m*/
        if (mDrawerLayout.isDrawerOpen(Gravity.START)) {
            mDrawerLayout.closeDrawer(Gravity.START);
        }

        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED, Gravity.START);
    }
}

From source file:com.benlinskey.greekreference.navigationdrawer.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 * @param fragmentId the id of this fragment in its activity's layout
 * @param drawerLayout the {@link DrawerLayout} containing this fragment's UI
 *//*  w  ww .ja  v  a  2 s  . co m*/
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_menu_white_24dp, /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close /* "close drawer" description for accessibility */
    ) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }

            if (!mUserLearnedDrawer) {
                // The user manually opened the drawer; store this flag to prevent auto-showing
                // the navigation drawer automatically in the future.
                mUserLearnedDrawer = true;
                SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity());
                sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply();
            }

            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }
    };

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer,
    // per the navigation drawer design guidelines.
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) {
        mDrawerLayout.openDrawer(mFragmentContainerView);
    }

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}