本文整理汇总了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;
}
}
示例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);
}
}
示例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();
}
示例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;
}
示例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();
}
}
示例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;
}
}
示例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));
}
示例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);
}
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}