Example usage for android.view Gravity LEFT

List of usage examples for android.view Gravity LEFT

Introduction

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

Prototype

int LEFT

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

Click Source Link

Document

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

Usage

From source file:com.dk.view.FolderDrawerLayout.java

public FolderDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);//  w  ww.ja  va 2 s  . co  m

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

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

public AllDrawerLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final float density = getResources().getDisplayMetrics().density;
    mMinDrawerMargin = (int) (MIN_DRAWER_MARGIN * density + 0.5f);
    final float minVel = MIN_FLING_VELOCITY * density;

    mLeftCallback = new ViewDragCallback(Gravity.LEFT);
    mRightCallback = new ViewDragCallback(Gravity.RIGHT);
    mTopCallback = new ViewDragCallback(Gravity.TOP);
    mBottomCallback = new ViewDragCallback(Gravity.BOTTOM);

    mLeftDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mLeftCallback);
    mLeftDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_LEFT);
    mLeftDragger.setMinVelocity(minVel);
    mLeftCallback.setDragger(mLeftDragger);

    mRightDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mRightCallback);
    mRightDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_RIGHT);
    mRightDragger.setMinVelocity(minVel);
    mRightCallback.setDragger(mRightDragger);

    mTopDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mTopCallback);
    mTopDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_TOP);
    mTopDragger.setMinVelocity(minVel);//from w  w w. j ava2  s. c o  m
    mTopCallback.setDragger(mTopDragger);

    mBottomDragger = ViewDragHelper.create(this, TOUCH_SLOP_SENSITIVITY, mBottomCallback);
    mBottomDragger.setEdgeTrackingEnabled(ViewDragHelper.EDGE_BOTTOM);
    mBottomDragger.setMinVelocity(minVel);
    mBottomCallback.setDragger(mBottomDragger);

    // So that we can catch the back button
    setFocusableInTouchMode(true);

    ViewCompat.setAccessibilityDelegate(this, new AccessibilityDelegate());
    ViewGroupCompat.setMotionEventSplittingEnabled(this, false);
}

From source file:com.chatwingsdk.activities.CommunicationActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int i = item.getItemId();
    if (i == android.R.id.home) {
        if (getDrawerLayout().isDrawerOpen(Gravity.LEFT)) {
            getDrawerLayout().closeDrawer(Gravity.LEFT);
        } else {// ww w .  j  a  v  a2s  .  c  om
            getDrawerLayout().openDrawer(Gravity.LEFT);
        }
        return true;
    } else {
        return mCurrentCommunicationMode.onOptionsItemSelected(item);
    }
}

From source file:com.hippo.drawerlayout.DrawerLayout.java

public void openDrawer(int gravity) {
    if (gravity == Gravity.LEFT) {
        openDrawer(mLeftDrawer);//from w w  w. j a va2s. co m
    } else if (gravity == Gravity.RIGHT) {
        openDrawer(mRightDrawer);
    }
}

From source file:com.cyanogenmod.filemanager.ui.widgets.DrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow.
 * The drawable provided must have a nonzero intrinsic width.
 *
 * @param shadowDrawable Shadow drawable to use at the edge of a drawer
 * @param gravity Which drawer the shadow should apply to
 *//*from   w  w  w .  j av a  2 s  . c  o  m*/
public void setDrawerShadow(Drawable shadowDrawable, int gravity) {
    /*
     * TODO Someone someday might want to set more complex drawables here.
     * They're probably nuts, but we might want to consider registering callbacks,
     * setting states, etc. properly.
     */

    final int absGravity = Gravity.getAbsoluteGravity(gravity, this.getLayoutDirection());
    if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
        invalidate();
    }
}

From source file:com.hippo.widget.slidingdrawerlayout.SlidingDrawerLayout.java

public void closeDrawer(int gravity) {
    if (gravity == Gravity.LEFT)
        closeDrawer(mLeftDrawer);// ww w. j a v  a2s .  c  o m
    else if (gravity == Gravity.RIGHT)
        closeDrawer(mRightDrawer);
}

From source file:com.example.carlitos.swipeitemrecycler.view.animation.swipe_item.swipeable.ItemSlidingAnimator.java

@SuppressLint("RtlHardcoded")
private static boolean slideInternalPreHoneycomb(RecyclerView.ViewHolder holder, boolean horizontal,
        int translationX, int translationY) {
    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }/*from ww  w.j a va  2  s  .  c o m*/

    final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView();

    final ViewGroup.LayoutParams lp = containerView.getLayoutParams();
    if (lp instanceof ViewGroup.MarginLayoutParams) {
        final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;

        mlp.leftMargin = translationX;
        mlp.rightMargin = -translationX;
        mlp.topMargin = translationY;
        mlp.bottomMargin = -translationY;

        if (lp instanceof FrameLayout.LayoutParams) {
            ((FrameLayout.LayoutParams) lp).gravity = Gravity.TOP | Gravity.LEFT;
        }

        containerView.setLayoutParams(mlp);
    } else {
        Log.w(TAG, "should use MarginLayoutParams supported view for compatibility on Android 2.3");
    }

    return false;
}

From source file:com.test.hwautotest.emmagee.service.EmmageeService.java

/**
 * create a floating window to show real-time data.
 *///from   w w  w . j a  v a  2s. c  o  m
private void createFloatingWindow() {
    SharedPreferences shared = getSharedPreferences("float_flag", Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor = shared.edit();
    editor.putInt("float", 1);
    editor.commit();
    windowManager = (WindowManager) getApplicationContext().getSystemService("window");
    wmParams = ((MyApplication) getApplication()).getMywmParams();
    wmParams.type = 2002;
    wmParams.flags |= 8;
    wmParams.gravity = Gravity.LEFT | 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();
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                // state = MotionEvent.ACTION_DOWN;
                startX = x;
                startY = y;
                mTouchStartX = event.getX();
                mTouchStartY = event.getY();
                Log.d("startP", "startX" + mTouchStartX + "====startY" + mTouchStartY);
                break;
            case MotionEvent.ACTION_MOVE:
                // state = MotionEvent.ACTION_MOVE;
                updateViewPosition();
                break;

            case MotionEvent.ACTION_UP:
                // state = MotionEvent.ACTION_UP;
                updateViewPosition();
                //               showImg();//?
                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.openwifi);
    //               if (buttonText.equals(wifiText)) {
    //                  wifiManager.setWifiEnabled(true);
    //                  btnWifi.setText(R.string.closewifi);
    //               } else {
    //                  wifiManager.setWifiEnabled(false);
    //                  btnWifi.setText(R.string.openwifi);
    //               }
    //            } catch (Exception e) {
    //               Toast.makeText(viFloatingWindow.getContext(), "?wifi",
    //                     Toast.LENGTH_LONG).show();
    //               Log.e(LOG_TAG, e.toString());
    //            }
    //         }
    //      });

    //?
    imgClose.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            showMemi();
        }
    });
}

From source file:com.github.shareme.gwsmaterialuikit.library.advancerv.swipeable.ItemSlidingAnimator.java

@SuppressLint("RtlHardcoded")
private static boolean slideInternalPreHoneycomb(RecyclerView.ViewHolder holder, boolean horizontal,
        int translationX, int translationY) {
    if (!(holder instanceof SwipeableItemViewHolder)) {
        return false;
    }//  w  w w  .  j ava  2  s . co m

    final View containerView = ((SwipeableItemViewHolder) holder).getSwipeableContainerView();

    final ViewGroup.LayoutParams lp = containerView.getLayoutParams();
    if (lp instanceof ViewGroup.MarginLayoutParams) {
        final ViewGroup.MarginLayoutParams mlp = (ViewGroup.MarginLayoutParams) lp;

        mlp.leftMargin = translationX;
        mlp.rightMargin = -translationX;
        mlp.topMargin = translationY;
        mlp.bottomMargin = -translationY;

        if (lp instanceof FrameLayout.LayoutParams) {
            ((FrameLayout.LayoutParams) lp).gravity = Gravity.TOP | Gravity.LEFT;
        }

        containerView.setLayoutParams(mlp);
    } else {
        Timber.w("should use MarginLayoutParams supported view for compatibility on Android 2.3");
    }

    return false;
}

From source file:com.abewy.android.apps.klyph.widget.KlyphDrawerLayout.java

/**
 * Set a simple drawable used for the left or right shadow.
 * The drawable provided must have a nonzero intrinsic width.
 *
 * @param shadowDrawable Shadow drawable to use at the edge of a drawer
 * @param gravity Which drawer the shadow should apply to
 *//*ww  w . ja  va  2s. com*/
public void setDrawerShadow(Drawable shadowDrawable, int gravity) {
    /*
     * TODO Someone someday might want to set more complex drawables here.
     * They're probably nuts, but we might want to consider registering callbacks,
     * setting states, etc. properly.
     */

    final int absGravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));
    if ((absGravity & Gravity.LEFT) == Gravity.LEFT) {
        mShadowLeft = shadowDrawable;
        invalidate();
    }
    if ((absGravity & Gravity.RIGHT) == Gravity.RIGHT) {
        mShadowRight = shadowDrawable;
        invalidate();
    }
}