當前位置: 首頁>>代碼示例>>Java>>正文


Java Gravity.RIGHT屬性代碼示例

本文整理匯總了Java中android.view.Gravity.RIGHT屬性的典型用法代碼示例。如果您正苦於以下問題:Java Gravity.RIGHT屬性的具體用法?Java Gravity.RIGHT怎麽用?Java Gravity.RIGHT使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.Gravity的用法示例。


在下文中一共展示了Gravity.RIGHT屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBindViewHolder

@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    Mensaje mensaje = mensajes.get(position);

    String msg = mensaje.getMensaje();
    holder.textViewMessage.setText(msg);

    int color = fetchColor(R.attr.colorPrimary);
    int gravity = Gravity.RIGHT;

    if (mensaje.isEnviaUsuario() == 0) {
        color = fetchColor(R.attr.colorAccent);
        gravity = Gravity.LEFT;
    }

    holder.textViewMessage.setBackgroundColor(color);
    LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) holder.textViewMessage.getLayoutParams();
    params.gravity = gravity;
    holder.textViewMessage.setLayoutParams(params);

}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:21,代碼來源:RVMensajeAdapter.java

示例2: 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

示例3: 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

示例4: 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

示例5: measuredOutContentStart

private void measuredOutContentStart(String content, int labelWidth) {
    Rect rect = new Rect();
    paintOuterText.getTextBounds(content, 0, content.length(), rect);
    switch (mGravity) {
        case Gravity.CENTER:
            drawOutContentStart = (int) ((measuredWidth - rect.width() - labelWidth) * 0.5);
            break;
        case Gravity.LEFT:
            drawOutContentStart = 0;
            break;
        case Gravity.RIGHT:
            if (labelWidth == 0) {
                labelWidth = LABELOFFSET;
            }
            drawOutContentStart = measuredWidth - rect.width() - labelWidth;
            break;
    }
}
 
開發者ID:crazysunj,項目名稱:Android-PickerDialog,代碼行數:18,代碼來源:WheelView.java

示例6: getContentStartH

protected int getContentStartH(int containerLeft, int containerRight, int contentWillSize, int contentMarginLeft, int contentMarginRight, int gravity) {
    if (gravity != -1 || gravity != 0) {
        int start;
        final int mask = Gravity.HORIZONTAL_GRAVITY_MASK;
        final int maskCenter = Gravity.CENTER_HORIZONTAL;
        final int maskEnd = Gravity.RIGHT;
        final int okGravity = gravity & mask;
        if (maskCenter == okGravity) {//center
            start = containerLeft + (containerRight - containerLeft - (contentWillSize + contentMarginRight - contentMarginLeft)) / 2;
        } else if (maskEnd == okGravity) {//end
            start = containerRight - contentWillSize - contentMarginRight;
        } else {//start
            start = containerLeft + contentMarginLeft;
        }
        return start;
    }
    return containerLeft + contentMarginLeft;
}
 
開發者ID:rexyren,項目名稱:PageScrollView,代碼行數:18,代碼來源:BaseViewGroup.java

示例7: getGravity

private int getGravity(String gravity) {
    switch (gravity) {
        case "CENTER":
            return Gravity.CENTER;
        case "CENTER_VERTICAL":
            return Gravity.CENTER_VERTICAL;
        case "TOP":
            return Gravity.TOP;
        case "LEFT":
            return Gravity.LEFT;
        case "RIGHT":
            return Gravity.RIGHT;
        case "BOTTOM":
            return Gravity.BOTTOM;
        case "START":
            return Gravity.START;
        case "END":
            return Gravity.END;
        default:
            return Gravity.CENTER_VERTICAL;
    }
}
 
開發者ID:cesardeazevedo,項目名稱:react-native-collapsing-toolbar,代碼行數:22,代碼來源:CollapsingToolbarLayoutManager.java

示例8: getDrawerLockMode

/**
 * Check the lock mode of the given drawer view.
 *
 * @param drawerView Drawer view to check lock mode
 * @return one of {@link #LOCK_MODE_UNLOCKED}, {@link #LOCK_MODE_LOCKED_CLOSED} or
 *         {@link #LOCK_MODE_LOCKED_OPEN}.
 */
@LockMode
public int getDrawerLockMode(View drawerView) {
  final int absGravity = getDrawerViewAbsoluteGravity(drawerView);
  if (absGravity == Gravity.LEFT) {
    return mLockModeLeft;
  } else if (absGravity == Gravity.RIGHT) {
    return mLockModeRight;
  }
  return LOCK_MODE_UNLOCKED;
}
 
開發者ID:rogues-dev,項目名稱:superglue,代碼行數:17,代碼來源:DebugDrawerLayout.java

示例9: init

public static void init(final Context context){
    sWindowManager = (WindowManager) context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
    sWindowLayoutParams = new WindowManager.LayoutParams(
            WindowManager.LayoutParams.WRAP_CONTENT,
            WindowManager.LayoutParams.WRAP_CONTENT,
            Build.VERSION.SDK_INT > Build.VERSION_CODES.N?
                    WindowManager.LayoutParams.TYPE_PHONE: WindowManager.LayoutParams.TYPE_TOAST,
            WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
            PixelFormat.TRANSLUCENT
    );
    sWindowLayoutParams.gravity = Gravity.TOP + Gravity.RIGHT;
    sView = LayoutInflater.from(context).inflate(R.layout.layout_floating_window,null);
}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:13,代碼來源:FloatingWindow.java

示例10: createApplicableHeaderLayoutParams

/**
 * {@inheritDoc}
 */
public LayoutParams createApplicableHeaderLayoutParams() {
	FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT);
	params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding);
	params.gravity = Gravity.TOP | Gravity.RIGHT;
	return params;
}
 
開發者ID:Dnet3,項目名稱:CustomAndroidOneSheeld,代碼行數:10,代碼來源:DefaultIndicatorLayout.java

示例11: updateTabStyles

private void updateTabStyles() {
        for (int i = 0; i < mTabCount; i++) {
            View tabView = mTabsContainer.getChildAt(i);
            tabView.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            TextView tv_tab_title = (TextView) tabView.findViewById(R.id.tv_tab_title);
            boolean selected = i == mCurrentTab;
            tv_tab_title.setTextColor(selected ? mTextSelectColor : mTextUnselectColor);
            tv_tab_title.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTextsize);
//            tv_tab_title.setPadding((int) mTabPadding, 0, (int) mTabPadding, 0);
            if (mTextAllCaps) {
                tv_tab_title.setText(tv_tab_title.getText().toString().toUpperCase());
            }

            if (mTextBold == TEXT_BOLD_BOTH) {
                tv_tab_title.getPaint().setFakeBoldText(true);
            } else if (mTextBold == TEXT_BOLD_NONE) {
                tv_tab_title.getPaint().setFakeBoldText(false);
            }

            ImageView iv_tab_icon = (ImageView) tabView.findViewById(R.id.iv_tab_icon);
            if (mIconVisible) {
                iv_tab_icon.setVisibility(View.VISIBLE);
//                CustomTabEntity tabEntity = mTabEntitys.get(i);
                iv_tab_icon.setColorFilter(selected ? selectIconColor : unSelectIconColor);
                LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                        mIconWidth <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconWidth,
                        mIconHeight <= 0 ? LinearLayout.LayoutParams.WRAP_CONTENT : (int) mIconHeight);
                if (mIconGravity == Gravity.LEFT) {
                    lp.rightMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.RIGHT) {
                    lp.leftMargin = (int) mIconMargin;
                } else if (mIconGravity == Gravity.BOTTOM) {
                    lp.topMargin = (int) mIconMargin;
                } else {
                    lp.bottomMargin = (int) mIconMargin;
                }

                iv_tab_icon.setLayoutParams(lp);
            } else {
                iv_tab_icon.setVisibility(View.GONE);
            }
        }
    }
 
開發者ID:Blankeer,項目名稱:MDWechat,代碼行數:43,代碼來源:CommonTabLayout.java

示例12: onMeasure

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int allPadding = _adjustText(getMeasuredWidth());
    int fontLen = mIsChecked ? mFontLenChecked : mFontLen;
    // 如果為精確測量 MeasureSpec.EXACTLY,則直接使用測量的大小,否則讓控件實現自適應
    // 如果你用了精確測量則 mHorizontalPadding 和 mVerticalPadding 會對最終大小判定無效
    int width = (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY) ?
            MeasureSpec.getSize(widthMeasureSpec) : allPadding + fontLen;
    int height = (MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY) ?
            MeasureSpec.getSize(heightMeasureSpec) : mVerticalPadding * 2 + mFontH;
    setMeasuredDimension(width, height);
    // 計算圖標放置位置
    if (mDecorateIcon != null || mDecorateIconChange != null) {
        int top = (height - mIconSize) / 2;
        int left;
        if (mIconGravity == Gravity.RIGHT) {
            int padding = (width - mIconSize - fontLen - mIconPadding) / 2;
            left = width - padding - mIconSize;
        } else {
            left = (width - mIconSize - fontLen - mIconPadding) / 2;
        }
        if (mTagMode == MODE_ICON_CHECK_CHANGE && mIsChecked && mDecorateIconChange != null) {
            mDecorateIconChange.setBounds(left, top, mIconSize + left, mIconSize + top);
        } else if (mDecorateIcon != null) {
            mDecorateIcon.setBounds(left, top, mIconSize + left, mIconSize + top);
        }
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:SimpleButton.java

示例13: onLayout

@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    // HorizontalScrollView is broken for Gravity.RIGHT. So we're fixing it.
    autoScrolling = false;
    int childWidth = getView().getWidth();
    super.onLayout(changed, left, top, right, bottom);
    int delta = getView().getWidth() - childWidth;
    AdvancedDisplay view = getView();
    ScrollableDisplay.LayoutParams p = (LayoutParams) view.getLayoutParams();
    int horizontalGravity = p.gravity & Gravity.HORIZONTAL_GRAVITY_MASK;
    int verticalGravity = p.gravity & Gravity.VERTICAL_GRAVITY_MASK;
    if(horizontalGravity == Gravity.RIGHT) {
        if(getScrollRange() > 0) {
            gravityRight = true;
            p.gravity = Gravity.LEFT | verticalGravity;
            view.setLayoutParams(p);
            super.onLayout(changed, left, top, right, bottom);
        }
    }
    else if(gravityRight) {
        if(getScrollRange() == 0) {
            gravityRight = false;
            p.gravity = Gravity.RIGHT | verticalGravity;
            view.setLayoutParams(p);
            super.onLayout(changed, left, top, right, bottom);
        }
    }
    if(gravityRight && delta > 0) {
        scrollBy(delta, 0);
        autoScrolling = true;
    }
}
 
開發者ID:gigabytedevelopers,項目名稱:CalcMate,代碼行數:32,代碼來源:ScrollableDisplay.java

示例14: 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

示例15: getGravity

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public int getGravity() {
    if(Utils.hasJellyBeanMR1()){
        Configuration config = getResources().getConfiguration();
        if(config.getLayoutDirection() != View.LAYOUT_DIRECTION_LTR){
            return Gravity.LEFT;
        }
    }
    return Gravity.RIGHT;
}
 
開發者ID:medalionk,項目名稱:simple-share-android,代碼行數:10,代碼來源:DocumentsActivity.java


注:本文中的android.view.Gravity.RIGHT屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。