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


Java Gravity.LEFT属性代码示例

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


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

示例1: showScreensharingBar

private void showScreensharingBar(boolean show) {
    WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    if (show) {
        mScreensharingBar = new ScreenSharingBar(MainActivity.this, this);

        //add screensharing bar on top of the screen
        WindowManager.LayoutParams params = new WindowManager.LayoutParams(
                WindowManager.LayoutParams.MATCH_PARENT,
                WindowManager.LayoutParams.WRAP_CONTENT,
                WindowManager.LayoutParams.TYPE_APPLICATION_PANEL,
                0 | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
                PixelFormat.TRANSLUCENT);
        params.gravity = Gravity.LEFT | Gravity.TOP;
        params.x = 0;
        params.y = 0;


        wm.addView(mScreensharingBar, params);
    } else {
        wm.removeView(mScreensharingBar);
        mScreensharingBar = null;
    }
}
 
开发者ID:opentok,项目名称:accelerator-sample-apps-android,代码行数:23,代码来源:MainActivity.java

示例2: init

public void init(ArrayList<BaseFragment> stack) {
    fragmentsStack = stack;
    containerViewBack = new LinearLayoutContainer(parentActivity);
    addView(containerViewBack);
    LayoutParams layoutParams = (LayoutParams) containerViewBack.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerViewBack.setLayoutParams(layoutParams);

    containerView = new LinearLayoutContainer(parentActivity);
    addView(containerView);
    layoutParams = (LayoutParams) containerView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    containerView.setLayoutParams(layoutParams);

    for (BaseFragment fragment : fragmentsStack) {
        fragment.setParentLayout(this);
    }
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:22,代码来源:ActionBarLayout.java

示例3: notifyDataSetChanged

/** 更新数据 */
public void notifyDataSetChanged() {
    mTabsContainer.removeAllViews();
    this.mTabCount = mTabEntitys.size();
    View tabView;
    for (int i = 0; i < mTabCount; i++) {
        if (mIconGravity == Gravity.LEFT) {
            tabView = View.inflate(mContext, R.layout.layout_tab_left, null);
        } else if (mIconGravity == Gravity.RIGHT) {
            tabView = View.inflate(mContext, R.layout.layout_tab_right, null);
        } else if (mIconGravity == Gravity.BOTTOM) {
            tabView = View.inflate(mContext, R.layout.layout_tab_bottom, null);
        } else {
            tabView = View.inflate(mContext, R.layout.layout_tab_top, null);
        }

        tabView.setTag(i);
        addTab(i, tabView);
    }

    updateTabStyles();
}
 
开发者ID:LonelyMushroom,项目名称:aarLibrary,代码行数:22,代码来源:CommonTabLayout.java

示例4: adjustBottomLines

/**
 * @return True, if adjustments were made that require the view to be invalidated.
 */
private boolean adjustBottomLines() {
  // Bail out if we have a zero width; lines will be adjusted during next layout.
  if (getWidth() == 0) {
    return false;
  }
  int destBottomLines;
  textPaint.setTextSize(bottomTextSize);
  if (tempErrorText != null || helperText != null) {
    Layout.Alignment alignment = (getGravity() & Gravity.RIGHT) == Gravity.RIGHT || isRTL() ?
      Layout.Alignment.ALIGN_OPPOSITE : (getGravity() & Gravity.LEFT) == Gravity.LEFT ?
      Layout.Alignment.ALIGN_NORMAL : Layout.Alignment.ALIGN_CENTER;
    textLayout = new StaticLayout(tempErrorText != null ? tempErrorText : helperText, textPaint, getWidth() - getBottomTextLeftOffset() - getBottomTextRightOffset() - getPaddingLeft() - getPaddingRight(), alignment, 1.0f, 0.0f, true);
    destBottomLines = Math.max(textLayout.getLineCount(), minBottomTextLines);
  } else {
    destBottomLines = minBottomLines;
  }
  if (bottomLines != destBottomLines) {
    getBottomLinesAnimator(destBottomLines).start();
  }
  bottomLines = destBottomLines;
  return true;
}
 
开发者ID:mityung,项目名称:XERUNG,代码行数:25,代码来源:MaterialAutoCompleteTextView.java

示例5: setDrawerShadow

/**
 * 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
 */
public void setDrawerShadow(Drawable shadowDrawable, @EdgeGravity 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();
  }
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:25,代码来源:DebugDrawerLayout.java

示例6: measuredOutContentStart

private void measuredOutContentStart(String content) {
    Rect rect = new Rect();
    paintOuterText.getTextBounds(content, 0, content.length(), rect);
    switch (mGravity) {
        case Gravity.CENTER:
            if (isOptions||label == null|| label.equals("")||!isCenterLabel) {
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.5);
            } else {//只显示中间label时,时间选择器内容偏左一点,留出空间绘制单位标签
                drawOutContentStart = (int) ((measuredWidth - rect.width()) * 0.25);
            }
            break;
        case Gravity.LEFT:
            drawOutContentStart = 0;
            break;
        case Gravity.RIGHT:
            drawOutContentStart = measuredWidth - rect.width()-(int)centerContentOffset;
            break;
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:WheelView.java

示例7: onMeasure

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int itemWidth;
    if (AndroidUtilities.isTablet()) {
        itemWidth = (AndroidUtilities.dp(490) - ((itemsCount + 1) * AndroidUtilities.dp(4))) / itemsCount;
    } else {
        itemWidth = (AndroidUtilities.displaySize.x - ((itemsCount + 1) * AndroidUtilities.dp(4))) / itemsCount;
    }

    for (int a = 0; a < itemsCount; a++) {
        LayoutParams layoutParams = (LayoutParams) photoVideoViews[a].getLayoutParams();
        layoutParams.topMargin = isFirst ? 0 : AndroidUtilities.dp(4);
        layoutParams.leftMargin = (itemWidth + AndroidUtilities.dp(4)) * a + AndroidUtilities.dp(4);
        layoutParams.width = itemWidth;
        layoutParams.height = itemWidth;
        layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
        photoVideoViews[a].setLayoutParams(layoutParams);
    }

    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec((isFirst ? 0 : AndroidUtilities.dp(4)) + itemWidth, MeasureSpec.EXACTLY));
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:21,代码来源:SharedPhotoVideoCell.java

示例8: updateItemPositions

/**
 * Recalculates the positions of each sub action item on demand.
 */
public void updateItemPositions() {
    // Only update if the menu is currently open
    if (!isOpen()) {
        return;
    }
    // recalculate x,y coordinates of Items
    calculateItemPositions();

    // Simply update layout params for each item
    for (int i = 0; i < subActionItems.size(); i++) {
        // This is currently done by giving them large margins
        final FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(subActionItems.get(i).width, subActionItems.get(i).height, Gravity.TOP | Gravity.LEFT);
        params.setMargins(subActionItems.get(i).x, subActionItems.get(i).y, 0, 0);
        subActionItems.get(i).view.setLayoutParams(params);
    }
}
 
开发者ID:HitRoxxx,项目名称:FloatingNew,代码行数:19,代码来源:FloatingActionMenu.java

示例9: dispatchChildInsets

@SuppressLint("NewApi")
private void dispatchChildInsets(View child, Object insets, int drawerGravity) {
    WindowInsets wi = (WindowInsets) insets;
        if (drawerGravity == Gravity.LEFT) {
            wi = wi.replaceSystemWindowInsets(wi.getSystemWindowInsetLeft(), wi.getSystemWindowInsetTop(), 0, wi.getSystemWindowInsetBottom());
        } else if (drawerGravity == Gravity.RIGHT) {
            wi = wi.replaceSystemWindowInsets(0, wi.getSystemWindowInsetTop(), wi.getSystemWindowInsetRight(), wi.getSystemWindowInsetBottom());
        }
        child.dispatchApplyWindowInsets(wi);
    }
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:10,代码来源:DrawerLayoutContainer.java

示例10: preparePopuPosition

void preparePopuPosition(View view, int selectionLeft, int selectionBottom, int selectionTop, int selectionRight, int handleLongerAxis) {
    int drawLocationY;
    int drawLocationX;
    int size;
    int width;
    int height;
    DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
    int screenWidth = displayMetrics.widthPixels;
    int screenHeight = displayMetrics.heightPixels;
    size = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    view.measure(size, size);
    height = view.getMeasuredHeight();
    width = view.getMeasuredWidth();
    drawLocationX = Math.min(
            screenWidth - width,
            Math.max(0,
                    (selectionLeft + ((selectionRight - selectionLeft) / 2)) - (width / 2)
            )
    );

    drawLocationY = selectionTop - height >= 0 ? selectionTop - height : (selectionBottom + height) + handleLongerAxis >= screenHeight ? handleLongerAxis > 0 ? selectionBottom - height : ((selectionBottom + selectionTop) / 2) - (height / 2) : selectionBottom + handleLongerAxis;
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams();
    layoutParams.leftMargin = drawLocationX;
    layoutParams.width = FrameLayout.LayoutParams.WRAP_CONTENT;
    layoutParams.height = FrameLayout.LayoutParams.WRAP_CONTENT;
    layoutParams.topMargin = drawLocationY;
    layoutParams.gravity = Gravity.TOP | Gravity.LEFT;
    view.setLayoutParams(layoutParams);
    //view.requestLayout();

}
 
开发者ID:fekracomputers,项目名称:IslamicLibraryAndroid,代码行数:31,代码来源:BookPageFragment.java

示例11: gravityToString

/**
 * Simple gravity to string - only supports LEFT and RIGHT for debugging output.
 *
 * @param gravity Absolute gravity value
 * @return LEFT or RIGHT as appropriate, or a hex string
 */
static String gravityToString(@EdgeGravity int gravity) {
  if ((gravity & Gravity.LEFT) == Gravity.LEFT) {
    return "LEFT";
  }
  if ((gravity & Gravity.RIGHT) == Gravity.RIGHT) {
    return "RIGHT";
  }
  return Integer.toHexString(gravity);
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:15,代码来源:DebugDrawerLayout.java

示例12: convertGravity

private static int convertGravity(View view, int gravity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        boolean isRtl = view.getLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
        if (gravity == Gravity.START) {
            gravity = isRtl ? Gravity.RIGHT : Gravity.LEFT;
        } else if (gravity == Gravity.END) {
            gravity = isRtl ? Gravity.LEFT : Gravity.RIGHT;
        }
    }
    return gravity;
}
 
开发者ID:rumaan,项目名称:file.io-app,代码行数:11,代码来源:MaterialIn.java

示例13: setMessage

public void setMessage(String message) {
    TextView messageView = new TextView(vContext);
    messageView.setText(message);
    messageView.setTextColor(Color.BLACK);
    messageView.setTextSize(17);
    messageView.setAllCaps(false);
    messageView.setGravity(Gravity.TOP|Gravity.LEFT);
    messageView.setPadding(margin_size * 5, margin_size * 3, margin_size * 5, margin_size * 3);
    
    FrameLayoutParams messageParams = new FrameLayoutParams(-1, -1, Gravity.TOP|Gravity.LEFT, new int[] { margin_size, size + margin_size * 3, margin_size, size + margin_size * 3 });
    super.addView(messageView, messageParams);
}
 
开发者ID:AstinPE,项目名称:StarchWindow,代码行数:12,代码来源:Window.java

示例14: isDrawerView

boolean isDrawerView(View child) {
  final int gravity = ((LayoutParams) child.getLayoutParams()).gravity;
  final int absGravity = GravityCompat.getAbsoluteGravity(gravity,
      ViewCompat.getLayoutDirection(child));
  return (absGravity & (Gravity.LEFT | Gravity.RIGHT)) != 0;
}
 
开发者ID:rogues-dev,项目名称:superglue,代码行数:6,代码来源:DebugDrawerLayout.java

示例15: onLayout

@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    final int count = getChildCount();

    int paddingBottom = getKeyboardHeight() <= AndroidUtilities.dp(20) ? captionEditText.getEmojiPadding() : 0;

    for (int i = 0; i < count; i++) {
        final View child = getChildAt(i);
        if (child.getVisibility() == GONE) {
            continue;
        }
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();

        final int width = child.getMeasuredWidth();
        final int height = child.getMeasuredHeight();

        int childLeft;
        int childTop;

        int gravity = lp.gravity;
        if (gravity == -1) {
            gravity = Gravity.TOP | Gravity.LEFT;
        }

        final int absoluteGravity = gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
        final int verticalGravity = gravity & Gravity.VERTICAL_GRAVITY_MASK;

        switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
            case Gravity.CENTER_HORIZONTAL:
                childLeft = (r - l - width) / 2 + lp.leftMargin - lp.rightMargin;
                break;
            case Gravity.RIGHT:
                childLeft = r - width - lp.rightMargin;
                break;
            case Gravity.LEFT:
            default:
                childLeft = lp.leftMargin;
        }

        switch (verticalGravity) {
            case Gravity.TOP:
                childTop = lp.topMargin;
                break;
            case Gravity.CENTER_VERTICAL:
                childTop = ((b - paddingBottom) - t - height) / 2 + lp.topMargin - lp.bottomMargin;
                break;
            case Gravity.BOTTOM:
                childTop = ((b - paddingBottom) - t) - height - lp.bottomMargin;
                break;
            default:
                childTop = lp.topMargin;
        }

        if (child == mentionListView) {
            if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) {
                childTop += AndroidUtilities.dp(400);
            } else {
                childTop -= captionEditText.getMeasuredHeight();
            }
        } else if (child == captionEditText) {
            if (!captionEditText.isPopupShowing() && !captionEditText.isKeyboardVisible() && captionEditText.getEmojiPadding() == 0) {
                childTop += AndroidUtilities.dp(400);
            }
        } else if (child == pickerView || child == captionTextViewNew || child == captionTextViewOld) {
            if (captionEditText.isPopupShowing() || captionEditText.isKeyboardVisible()) {
                childTop += AndroidUtilities.dp(400);
            }
        } else if (captionEditText.isPopupView(child)) {
            childTop = captionEditText.getBottom();
        }
        child.layout(childLeft, childTop, childLeft + width, childTop + height);
    }

    notifyHeightChanged();
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:75,代码来源:PhotoViewer.java


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