Example usage for android.view Gravity NO_GRAVITY

List of usage examples for android.view Gravity NO_GRAVITY

Introduction

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

Prototype

int NO_GRAVITY

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

Click Source Link

Document

Constant indicating that no gravity has been set

Usage

From source file:meizhi.meizhi.malin.utils.WindowInsetsCompatUtil.java

public static WindowInsetsCompat copy(WindowInsetsCompat source) {
    return copyExcluded(source, Gravity.NO_GRAVITY);
}

From source file:mobi.cangol.mobile.navigation.DrawerMenuLayout.java

public DrawerMenuLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    mMenuView = new FrameLayout(context);
    mContentView = new FrameLayout(context);
    mMaskView = new FrameLayout(context);

    DrawerLayout.LayoutParams lp1 = new DrawerLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT);/*  w  ww  .ja va  2 s. c  o  m*/
    lp1.gravity = Gravity.NO_GRAVITY;
    mContentView.setId(R.id.content_view);
    this.addView(mContentView, lp1);

    LayoutParams lp3 = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lp3.gravity = Gravity.NO_GRAVITY;
    mMaskView.setId(R.id.mask_view);
    mMaskView.setVisibility(GONE);
    this.addView(mMaskView, lp3);

    int width = (int) (mMenuWidth * context.getResources().getDisplayMetrics().widthPixels);
    DrawerLayout.LayoutParams lp2 = new DrawerLayout.LayoutParams(width, LayoutParams.MATCH_PARENT);
    lp2.gravity = Gravity.LEFT;
    mMenuView.setId(R.id.menu_view);
    this.addView(mMenuView, lp2);

}

From source file:com.example.android.supportv7.widget.PopupMenuActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.popup_menu_activity);

    mDateFormat = new SimpleDateFormat("HH:mm:ss.SSS");

    final ViewGroup container = findViewById(R.id.container);
    mLog = (TextView) container.findViewById(R.id.log);

    final SwitchCompat elevationToggle = (SwitchCompat) container.findViewById(R.id.elevation_toggle);
    final Button button = (Button) container.findViewById(R.id.test_button);
    button.setOnClickListener(new View.OnClickListener() {
        @Override//from  ww w .j  a va  2 s .  c  om
        public void onClick(View v) {
            // Do we need to use a custom style that removes elevation?
            boolean useDefaultElevation = elevationToggle.isChecked();

            PopupMenu popupMenu = null;
            if (useDefaultElevation) {
                popupMenu = new PopupMenu(container.getContext(), button);
            } else {
                popupMenu = new PopupMenu(container.getContext(), button, Gravity.NO_GRAVITY, 0,
                        R.style.CustomPopupNoElevation);
            }

            final MenuInflater menuInflater = popupMenu.getMenuInflater();
            menuInflater.inflate(R.menu.popup_menu, popupMenu.getMenu());
            final MenuItem editItem = popupMenu.getMenu().findItem(R.id.action_edit);
            MenuItemCompat.setContentDescription(editItem, getString(R.string.popup_menu_edit_description));
            MenuItemCompat.setTooltipText(editItem, getString(R.string.popup_menu_edit_tooltip));

            // Register a listener to be notified when a menu item in our popup menu has
            // been clicked.
            popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                @Override
                public boolean onMenuItemClick(MenuItem item) {
                    addToLog("Item '" + item.getTitle() + "' clicked");
                    return true;
                }
            });

            // Register a listener to be notified when our popup menu is dismissed.
            popupMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {
                @Override
                public void onDismiss(PopupMenu menu) {
                    addToLog("Popup menu dismissed");
                }
            });

            // Show the popup menu
            popupMenu.show();
        }
    });
}

From source file:org.hedgewars.hedgeroid.Downloader.DownloadListActivity.java

public void onNewItemSelected(DownloadPackage _task, int x, int minX, int maxX, int size) {
    if (layout != null) {
        if (!_task.equals(task)) {//if it's a new task refresh the whole thing
            task = _task;/*ww  w .  java 2s .  c o m*/
            layout.removeView(infoView);
            infoView = null;
        }

        if (infoView == null) {//build iv if it hasn't been created yet
            infoView = this.getLayoutInflater().inflate(R.layout.download_info, layout, false);
            FrameLayout.LayoutParams params = (android.widget.FrameLayout.LayoutParams) infoView
                    .getLayoutParams();
            params.gravity = Gravity.NO_GRAVITY;
            params.height = size;
            arrow = (ImageView) infoView.findViewById(R.id.arrow);
            arrow.setVisibility(View.INVISIBLE);
            halfSize = size / 2;

            Button yes = (Button) infoView.findViewById(R.id.download);
            Button no = (Button) infoView.findViewById(R.id.cancel);
            yes.setOnClickListener(yesClicker);
            no.setOnClickListener(noClicker);

            layout.addView(infoView, params);
        }
    }
}

From source file:dg.shenm233.drag2expandview.Drag2ExpandView.java

public Drag2ExpandView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    if (attrs != null) {
        TypedArray o = context.obtainStyledAttributes(attrs, OTHER_ATTRS);
        if (o != null) {
            int gravity = o.getInt(0, Gravity.NO_GRAVITY);
            setGravity(gravity);/*from   w  ww  . j  a v a  2s. c om*/
            o.recycle();
        }

        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.Drag2ExpandView);
        if (a != null) {
            mHeaderHeight = a.getDimensionPixelSize(R.styleable.Drag2ExpandView_sHeaderHeight, -1);
            mScrollableViewResId = a.getResourceId(R.styleable.Drag2ExpandView_sScrollableView, -1);
            mDragViewResId = a.getResourceId(R.styleable.Drag2ExpandView_sViewToDrag, -1);
            mAnchorOffset = a.getFloat(R.styleable.Drag2ExpandView_sAnchorOffset, 1.0f);
            a.recycle();
        }
    }

    mViewDragHelper = ViewDragHelper.create(this, 1.0f, mViewDragCallback = new ViewDragCallback());
    mScrollableViewHelper = new ScrollableViewHelper();

}

From source file:org.liberty.android.fantastischmemo.ui.CardFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.card_layout, container, false);
    cardTextView = (TextView) v.findViewById(R.id.card_text_view);
    rootView = (LinearLayout) v.findViewById(R.id.root);

    cardTextView.setText(mCardText);/*from www  .j ava2 s .c om*/

    if (cardOnClickListener != null) {
        rootView.setOnClickListener(cardOnClickListener);
    }

    if (cardOnLongClickListener != null) {
        rootView.setOnLongClickListener(cardOnLongClickListener);
    }

    if (textOnClickListener != null) {
        cardTextView.setOnClickListener(textOnClickListener);
    }

    if (textOnLongClickListener != null) {
        cardTextView.setOnLongClickListener(textOnLongClickListener);
    }

    cardTextView.setTextColor(textColor);

    rootView.setBackgroundColor(backgroundColor);

    if (fontFile != null && new File(fontFile).exists()) {
        Typeface qt = Typeface.createFromFile(fontFile);
        cardTextView.setTypeface(qt);
    }

    cardTextView.setTextSize(fontSize);

    // It is tricky to set up the alignment of the text.
    if (textAlignment == Gravity.CENTER) {
        cardTextView.setGravity(Gravity.CENTER);
        rootView.setGravity(Gravity.CENTER);
    } else if (textAlignment == Gravity.RIGHT) {
        cardTextView.setGravity(Gravity.RIGHT);
        rootView.setGravity(Gravity.NO_GRAVITY);
    } else {
        cardTextView.setGravity(Gravity.LEFT);
        rootView.setGravity(Gravity.NO_GRAVITY);
    }

    return v;
}

From source file:org.hedgewars.hedgeroid.Downloader.DownloadListActivity.java

public void onViewMoved(int x, int minX, int maxX) {
    if (halfSize == -1) {
        if (infoView.getHeight() != 0) {
            halfSize = infoView.getHeight() / 2;
        }//from   w ww.  jav  a 2s .  c  o m
    }
    if (layout != null && infoView != null) {
        FrameLayout.LayoutParams params = ((FrameLayout.LayoutParams) infoView.getLayoutParams());
        if (x - halfSize < minX) {
            params.topMargin = 0;
            arrow.setVisibility(View.INVISIBLE);
            params.gravity = Gravity.TOP;
        } else if (x + halfSize >= maxX) {
            params.topMargin = 0;
            arrow.setVisibility(View.INVISIBLE);
            params.gravity = Gravity.BOTTOM;
        } else {
            params.topMargin = x - halfSize;
            params.gravity = Gravity.NO_GRAVITY;
            arrow.setVisibility(View.VISIBLE);
        }

        infoView.requestLayout();

    }
}

From source file:android.support.design.widget.HeaderScrollingViewBehavior.java

private static int resolveGravity(int gravity) {
    return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity;
}

From source file:li.barter.widgets.FullWidthDrawerLayout.java

boolean isChildAContentView(final View child) {
    return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY;
}

From source file:org.loon.framework.android.game.LGameActivity.java

public void initialization(Bundle icicle, final boolean landscape, final boolean openAD, final LAD lad,
        final String publisherId, final String keywords, final int requestInterval) {
    LSystem.gc();//from   w w  w  . ja  va 2  s  . c  om
    this.androidSelect = -2;
    frameLayout = new FrameLayout(LGameActivity.this);
    super.onCreate(icicle);
    if (openAD) {
        // setVolumeControlStream(AudioManager.STREAM_MUSIC);
        AdManager.setPublisherId(publisherId);
        AdManager.setTestDevices(new String[] { "" });
        AdManager.setAllowUseOfLocation(true);
        view = new LGameView(LGameActivity.this, landscape);
        adview = new AdView(LGameActivity.this);
        adview.setKeywords(keywords);
        adview.setRequestInterval(requestInterval);
        adview.setGravity(Gravity.NO_GRAVITY);
        RelativeLayout rl = new RelativeLayout(LGameActivity.this);
        RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT);
        if (lad == LAD.LEFT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_LEFT, 1);
        } else if (lad == LAD.RIGHT) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else if (lad == LAD.TOP) {
            lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1);
        } else {
            lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1);
        }
        visible = true;
        adview.requestFreshAd();
        frameLayout.addView(view);
        rl.addView(adview, lp);
        frameLayout.addView(rl);
    } else {
        view = new LGameView(LGameActivity.this, landscape);
        frameLayout.addView(view);
    }
    if (view != null) {
        gameHandler = view.getGameHandler();
    }

}