当前位置: 首页>>代码示例>>Java>>正文


Java Gravity.NO_GRAVITY属性代码示例

本文整理汇总了Java中android.view.Gravity.NO_GRAVITY属性的典型用法代码示例。如果您正苦于以下问题:Java Gravity.NO_GRAVITY属性的具体用法?Java Gravity.NO_GRAVITY怎么用?Java Gravity.NO_GRAVITY使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.Gravity的用法示例。


在下文中一共展示了Gravity.NO_GRAVITY属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: showAsDropDown

/**
 * fix showAsDropDown when android api ver is over N
 * <p>
 * https://code.google.com/p/android/issues/detail?id=221001
 *
 * @param anchor
 * @param xoff
 * @param yoff
 * @param gravity
 */
@Override
public void showAsDropDown(View anchor, int xoff, int yoff, int gravity) {
    if (isFixAndroidN && anchor != null) {
        int[] anchorLocation = new int[2];
        anchor.getLocationInWindow(anchorLocation);
        Activity activity = (Activity) anchor.getContext();

        xoff = anchorLocation[0] + xoff;
        yoff = anchorLocation[1] + anchor.getHeight() + yoff;
        setFocusable(false);
        super.showAtLocation((activity).getWindow().getDecorView(), Gravity.NO_GRAVITY, xoff, yoff);
        initSystemBar(getContentView());
        setFocusable(true);
        update();
    } else {
        if (isOverAndroidN) {
            setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
        }
        setFocusable(false);
        super.showAsDropDown(anchor, xoff, yoff, gravity);
        initSystemBar(getContentView());
        setFocusable(true);
        update();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:35,代码来源:PopupWindowProxy.java

示例2: onAttachedToWindow

@Override
protected void onAttachedToWindow() {
    super.onAttachedToWindow();
    if (isInEditMode() && previewLayoutId != -1) {
        for (int i = NUMBER_OF_SIMULTANEOUS_CARDS - 1; i >= 0; i--) {
            View view = LayoutInflater.from(getContext()).inflate(previewLayoutId, this, false);
            FrameLayout.LayoutParams params = (LayoutParams) view.getLayoutParams();

            int offset = (int) (i * CARD_SPACING);
            // All cards are placed in absolute coordinates, so disable gravity if we have any
            params.gravity = Gravity.NO_GRAVITY;
            // We can't user translations here, for some reason it's not rendered properly in preview
            params.topMargin = offset;
            view.setLayoutParams(params);
            addViewInLayout(view, -1, params, true);
        }
        setZTranslations();
    }
}
 
开发者ID:pao11,项目名称:SwipeDeckRelease,代码行数:19,代码来源:SwipeDeck.java

示例3: getAlignment

public Layout.Alignment getAlignment() {
  boolean isRtl = getLayoutDirection() == YogaDirection.RTL;
  switch (mAlignment) {
    // Layout.Alignment.RIGHT and Layout.Alignment.LEFT are @hide :(
    case Gravity.LEFT:
      int index = isRtl ? ALIGNMENT_RIGHT : ALIGNMENT_LEFT;
      return Layout.Alignment.values()[index];
    case Gravity.RIGHT:
      index = isRtl ? ALIGNMENT_LEFT : ALIGNMENT_RIGHT;
      return Layout.Alignment.values()[index];
    case Gravity.CENTER:
      return Layout.Alignment.ALIGN_CENTER;
    case Gravity.NO_GRAVITY:
    default:
      return Layout.Alignment.ALIGN_NORMAL;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:17,代码来源:RCTText.java

示例4: showAsDropDownAtLocation

public void showAsDropDownAtLocation(View parent, int contentHeight, int x, int y) {
    int screenWidth = getContentView().getResources().getDisplayMetrics().widthPixels;
    int screenHeight = getContentView().getResources().getDisplayMetrics().heightPixels;
    int width = getContentView().getMeasuredWidth();
    int height = getContentView().getMeasuredHeight();
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) mLittleTriangle.getLayoutParams();
    if (x + width > screenWidth) {
        params.leftMargin = x + width - screenWidth;
    } else if (x < 0) {
        params.leftMargin = x;
    } else {
        params.leftMargin = 0;
    }
    if (y + height > screenHeight) {
        getContentView().setRotation(180);
        mRecyclerView.setRotation(180);
        params.leftMargin = -params.leftMargin;
        y -= contentHeight + height;
    } else {
        getContentView().setRotation(0);
        mRecyclerView.setRotation(0);
    }
    mLittleTriangle.setLayoutParams(params);
    super.showAtLocation(parent, Gravity.NO_GRAVITY, x, y);
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:25,代码来源:BubblePopupMenu.java

示例5: setTextAlign

@ReactProp(name = ViewProps.TEXT_ALIGN)
public void setTextAlign(@Nullable String textAlign) {
  if (textAlign == null || "auto".equals(textAlign)) {
    mTextAlign = Gravity.NO_GRAVITY;
  } else if ("left".equals(textAlign)) {
    mTextAlign = Gravity.LEFT;
  } else if ("right".equals(textAlign)) {
    mTextAlign = Gravity.RIGHT;
  } else if ("center".equals(textAlign)) {
    mTextAlign = Gravity.CENTER_HORIZONTAL;
  } else if ("justify".equals(textAlign)) {
    // Fallback gracefully for cross-platform compat instead of error
    mTextAlign = Gravity.LEFT;
  } else {
    throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign);
  }
  markUpdated();
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:ReactTextShadowNode.java

示例6: setTextAlign

@ReactProp(name = ViewProps.TEXT_ALIGN)
public void setTextAlign(@Nullable String textAlign) {
  if (textAlign == null || "auto".equals(textAlign)) {
    mAlignment = Gravity.NO_GRAVITY;
  } else if ("left".equals(textAlign)) {
    // left and right may yield potentially different results (relative to non-nodes) in cases
    // when supportsRTL="true" in the manifest.
    mAlignment = Gravity.LEFT;
  } else if ("right".equals(textAlign)) {
    mAlignment = Gravity.RIGHT;
  } else if ("center".equals(textAlign)) {
    mAlignment = Gravity.CENTER;
  } else {
    throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign);
  }

  notifyChanged(false);
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:18,代码来源:RCTText.java

示例7: onTargetAlignmentChanged

@OnCheckedChanged({ R.id.target_align_start, R.id.target_align_center, R.id.target_align_end })
void onTargetAlignmentChanged(RadioButton button, boolean isChecked) {
    if (isChecked) {
        int alignment = Gravity.NO_GRAVITY;
        switch (button.getId()) {
            case R.id.target_align_start:
                alignment = Gravity.START;
                break;
            case R.id.target_align_center:
                alignment = Gravity.CENTER_HORIZONTAL;
                break;
            case R.id.target_align_end:
                alignment = Gravity.END;
                break;
        }
        onUpdateListener.updateTargetTextAlignment(alignment);
    }
}
 
开发者ID:shazam,项目名称:reflow-animator,代码行数:18,代码来源:AdvancedOptionsDialogFragment.java

示例8: onRestoreInstanceState

@Override
protected void onRestoreInstanceState(Parcelable state) {
  final SavedState ss = (SavedState) state;
  super.onRestoreInstanceState(ss.getSuperState());

  if (ss.openDrawerGravity != Gravity.NO_GRAVITY) {
    final View toOpen = findDrawerWithGravity(ss.openDrawerGravity);
    if (toOpen != null) {
      openDrawer(toOpen);
    }
  }

  setDrawerLockMode(ss.lockModeLeft, Gravity.LEFT);
  setDrawerLockMode(ss.lockModeRight, Gravity.RIGHT);
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:15,代码来源:DebugDrawerLayout.java

示例9: addView

@Override
public void addView(View child, int index, ViewGroup.LayoutParams params) {
    if (child == null) return;
    int gravity = Gravity.NO_GRAVITY;
    try {
        gravity = (Integer) params.getClass().getField("gravity").get(params);
    } catch (Exception e) {
        e.printStackTrace();
    }

    if (gravity > 0) {
        gravity = GravityCompat.getAbsoluteGravity(gravity, ViewCompat.getLayoutDirection(this));

        if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
            mDragEdges.put(DragEdge.Left, child);
        }
        if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
            mDragEdges.put(DragEdge.Right, child);
        }
        if ((gravity & Gravity.TOP) == Gravity.TOP) {
            mDragEdges.put(DragEdge.Top, child);
        }
        if ((gravity & Gravity.BOTTOM) == Gravity.BOTTOM) {
            mDragEdges.put(DragEdge.Bottom, child);
        }
    } else {
        for (Map.Entry<DragEdge, View> entry : mDragEdges.entrySet()) {
            if (entry.getValue() == null) {
                //means used the drag_edge attr, the no gravity child should be use set
                mDragEdges.put(entry.getKey(), child);
                break;
            }
        }
    }
    if (child.getParent() == this) {
        return;
    }
    super.addView(child, index, params);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:SwipeLayout.java

示例10: generateLayoutParams

@Override
protected LayoutParams generateLayoutParams(ViewGroup.LayoutParams p) {
    if (p instanceof LayoutParams) {
        LayoutParams result = new LayoutParams((LayoutParams) p);
        if (result.gravity <= Gravity.NO_GRAVITY) {
            result.gravity = Gravity.CENTER_VERTICAL;
        }
        return result;
    }
    return generateDefaultLayoutParams();
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:11,代码来源:ActionMenuView.java

示例11: parseGravity

private static int parseGravity(String value) {
    int gravity = Gravity.NO_GRAVITY;
    String[] parts = value.toLowerCase().split("[|]");
    for (String part : parts) {
        switch (part) {
            case "center":
                gravity = gravity | Gravity.CENTER;
                break;
            case "left":
            case "textStart":
                gravity = gravity | Gravity.LEFT;
                break;
            case "right":
            case "textEnd":
                gravity = gravity | Gravity.RIGHT;
                break;
            case "top":
                gravity = gravity | Gravity.TOP;
                break;
            case "bottom":
                gravity = gravity | Gravity.BOTTOM;
                break;
            case "center_horizontal":
                gravity = gravity | Gravity.CENTER_HORIZONTAL;
                break;
            case "center_vertical":
                gravity = gravity | Gravity.CENTER_VERTICAL;
                break;
        }
    }
    return gravity;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:32,代码来源:DynamicLayoutInflator.java

示例12: showCategoriesPopupMenu

private void showCategoriesPopupMenu(final View view) {
    final String allCategories = getString(R.string.all_categories);

    final PopupMenu popupMenu =
            new PopupMenu(this, view, Gravity.NO_GRAVITY, R.attr.actionOverflowMenuStyle, 0);

    popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(final MenuItem item) {
            final String title = String.valueOf(item.getTitle());

            getFeedSubscriptionsFragment().changeSelectedCategory(title);

            return true;
        }
    });

    final Menu menu = popupMenu.getMenu();

    menu.add(allCategories);

    final Set<String> categories = SharedPrefUtils.getFeedMetaDataCategories(this);

    for (final String category : categories) {
        menu.add(category);
    }

    popupMenu.setGravity(Gravity.TOP);
    popupMenu.show();
}
 
开发者ID:Applications-Development,项目名称:SimpleRssReader,代码行数:30,代码来源:MainActivity.java

示例13: resolveGravity

private static int resolveGravity(int gravity) {
    return gravity == Gravity.NO_GRAVITY ? GravityCompat.START | Gravity.TOP : gravity;
}
 
开发者ID:huyongli,项目名称:UCMainViewForBehavior,代码行数:3,代码来源:HeaderScrollingViewBehavior.java

示例14: ArcTipViewController

private ArcTipViewController(Context application) {
        mContext = application;
        mWindowManager = (WindowManager) application.getSystemService(Context.WINDOW_SERVICE);

        MAX_LENGTH = DEFAULT_MAX_LENGTH *SPHelper.getFloat(ConstantUtil.FLOATVIEW_SIZE,100)/ 100f;
        MIN_LENGTH = DEFAULT_MIN_LENGTH *SPHelper.getFloat(ConstantUtil.FLOATVIEW_SIZE,100)/ 100f;

        int resourceId = application.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            mStatusBarHeight = application.getResources().getDimensionPixelSize(resourceId);
        }


        mainHandler = new Handler(Looper.getMainLooper()) {
            @Override
            public void handleMessage(Message msg) {
                synchronized (ArcTipViewController.this) {
                    switch (msg.what) {
                        case MOVETOEDGE:
                            int desX = (int) msg.obj;
                            if (desX == 0) {
                                layoutParams.x = (int) (layoutParams.x - density * 10);
                                if (layoutParams.x < 0) {
                                    layoutParams.x = 0;
                                }
                            } else {
                                layoutParams.x = (int) (layoutParams.x + density * 10);
                                if (layoutParams.x > desX) {
                                    layoutParams.x = desX;
                                }
                            }
                            updateViewPosition(layoutParams.x, layoutParams.y);
                            if (layoutParams.x != desX) {
                                mainHandler.sendMessageDelayed(mainHandler.obtainMessage(MOVETOEDGE, desX), 10);
                            } else {
                                isMovingToEdge = false;
                                if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
                                    SPHelper.save(ConstantUtil.FLOAT_VIEW_PORT_X, layoutParams.x);
                                    SPHelper.save(ConstantUtil.FLOAT_VIEW_PORT_Y, layoutParams.y);
                                } else {
                                    SPHelper.save(ConstantUtil.FLOAT_VIEW_LAND_X, layoutParams.x);
                                    SPHelper.save(ConstantUtil.FLOAT_VIEW_LAND_Y, layoutParams.y);
                                }
                            }
                            break;
                        case HIDETOEDGE:
                            if (layoutParams.x <= mScaledTouchSlop && ((layoutParams.gravity & (Gravity.TOP | Gravity.LEFT)) == (Gravity.TOP | Gravity.LEFT))) {
                                floatImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.floatview_hide_left));
                            } else {
                                floatImageView.setImageDrawable(mContext.getResources().getDrawable(R.mipmap.floatview_hide_right));
                            }
                            iconFloatView.setOnTouchListener(ArcTipViewController.this);
                            acrFloatView.setOnTouchListener(ArcTipViewController.this);
                            floatImageView.setContentDescription(mContext.getString(R.string.float_view_hide));
                            LinearLayout.LayoutParams layoutParams_ = (LinearLayout.LayoutParams) floatImageView.getLayoutParams();
                            layoutParams_.width = (int) ((int) ViewUtil.dp2px(DEFAULT_MIN_WIDTH_HIDE)*SPHelper.getFloat(ConstantUtil.FLOATVIEW_SIZE,100)/ 100f);
                            layoutParams_.height = (int) ViewUtil.dp2px(MIN_LENGTH);
                            layoutParams_.gravity = Gravity.NO_GRAVITY;
                            floatImageView.setLayoutParams(layoutParams_);
                            floatImageView.setPadding(0,0,0,0);
                            //TODO 不贴边的问题
//                            layoutParams.width = (int) ViewUtil.dp2px(DEFAULT_MIN_WIDTH_HIDE);
                            reuseSavedWindowMangerPosition((int) (ViewUtil.dp2px(DEFAULT_MIN_WIDTH_HIDE)*SPHelper.getFloat(ConstantUtil.FLOATVIEW_SIZE,100)/ 100f), ViewUtil.dp2px(MIN_LENGTH));
                            updateViewPosition(layoutParams.x, layoutParams.y);

                            break;
                    }
                }
            }
        };

        mActionListener = new ArrayList<>();
        mScaledTouchSlop = (int) (ViewUtil.dp2px(DEFAULT_MIN_WIDTH_HIDE)*SPHelper.getFloat(ConstantUtil.FLOATVIEW_SIZE,100)/ 100f);
        initView();
        applySizeChange();
        isRemoved = true;
    }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:77,代码来源:ArcTipViewController.java

示例15: isContentView

boolean isContentView(View child) {
  return ((LayoutParams) child.getLayoutParams()).gravity == Gravity.NO_GRAVITY;
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:3,代码来源:DebugDrawerLayout.java


注:本文中的android.view.Gravity.NO_GRAVITY属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。