当前位置: 首页>>代码示例>>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;未经允许,请勿转载。