當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。