Java Code Examples for android.view.Gravity#FILL
The following examples show how to use
android.view.Gravity#FILL .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WheelView.java From X-Alarm with GNU Affero General Public License v3.0 | 6 votes |
/** * Describes how the foreground is positioned. Defaults to START and TOP. * * @param foregroundGravity See {@link android.view.Gravity} * * @see #getForegroundGravity() */ public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mWheelForeground != null) { Rect padding = new Rect(); mWheelForeground.getPadding(padding); } requestLayout(); } }
Example 2
Source File: ForegroundDelegate.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 6 votes |
public void setForegroundGravity(View view, int foregroundGravity) { if (view != null) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); mForeground.getPadding(padding); } view.requestLayout(); } } }
Example 3
Source File: ShadowView.java From YCCardView with Apache License 2.0 | 6 votes |
@Override public void setForeground(Drawable foreground) { if (foregroundDrawable != null) { foregroundDrawable.setCallback(null); unscheduleDrawable(foregroundDrawable); } foregroundDrawable = foreground; updateForegroundColor(); if (foreground != null) { setWillNotDraw(false); foreground.setCallback(this); if (foreground.isStateful()) { foreground.setState(getDrawableState()); } if (foregroundDrawGravity == Gravity.FILL) { Rect padding = new Rect(); foreground.getPadding(padding); } } requestLayout(); invalidate(); }
Example 4
Source File: ShadowView.java From YCCardView with Apache License 2.0 | 6 votes |
@Override public void setForegroundGravity(int foregroundGravity) { if (foregroundDrawGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity = foregroundGravity | Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity = foregroundGravity | Gravity.TOP; } foregroundDrawGravity = foregroundGravity; if (foregroundDrawGravity == Gravity.FILL && foregroundDrawable != null) { Rect padding = new Rect(); foregroundDrawable.getPadding(padding); } requestLayout(); } }
Example 5
Source File: VerticalTabLayout.java From VerticalTabLayout with Apache License 2.0 | 6 votes |
public VerticalTabLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mContext = context; mTabSelectedListeners = new ArrayList<>(); TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.VerticalTabLayout); mColorIndicator = typedArray.getColor(R.styleable.VerticalTabLayout_indicator_color, context.getResources().getColor(R.color.colorAccent)); mIndicatorWidth = (int) typedArray.getDimension(R.styleable.VerticalTabLayout_indicator_width, DisplayUtil.dp2px(context, 3)); mIndicatorCorners = typedArray.getDimension(R.styleable.VerticalTabLayout_indicator_corners, 0); mIndicatorGravity = typedArray.getInteger(R.styleable.VerticalTabLayout_indicator_gravity, Gravity.LEFT); if (mIndicatorGravity == 3) { mIndicatorGravity = Gravity.LEFT; } else if (mIndicatorGravity == 5) { mIndicatorGravity = Gravity.RIGHT; } else if (mIndicatorGravity == 119) { mIndicatorGravity = Gravity.FILL; } mTabMargin = (int) typedArray.getDimension(R.styleable.VerticalTabLayout_tab_margin, 0); mTabMode = typedArray.getInteger(R.styleable.VerticalTabLayout_tab_mode, TAB_MODE_FIXED); int defaultTabHeight = LinearLayout.LayoutParams.WRAP_CONTENT; mTabHeight = (int) typedArray.getDimension(R.styleable.VerticalTabLayout_tab_height, defaultTabHeight); typedArray.recycle(); }
Example 6
Source File: ForegroundLinearLayout.java From RetailStore with Apache License 2.0 | 6 votes |
/** * Describes how the foreground is positioned. Defaults to START and TOP. * * @param foregroundGravity See {@link Gravity} * * @see #getForegroundGravity() */ public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); mForeground.getPadding(padding); } requestLayout(); } }
Example 7
Source File: FrameLayout.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Describes how the foreground is positioned. Defaults to START and TOP. * * @param foregroundGravity See {@link android.view.Gravity} * * @see #getForegroundGravity() * * @attr ref android.R.styleable#View_foregroundGravity */ @android.view.RemotableViewMethod public void setForegroundGravity(int foregroundGravity) { if (getForegroundGravity() != foregroundGravity) { super.setForegroundGravity(foregroundGravity); // calling get* again here because the set above may apply default constraints final Drawable foreground = getForeground(); if (getForegroundGravity() == Gravity.FILL && foreground != null) { Rect padding = new Rect(); if (foreground.getPadding(padding)) { mForegroundPaddingLeft = padding.left; mForegroundPaddingTop = padding.top; mForegroundPaddingRight = padding.right; mForegroundPaddingBottom = padding.bottom; } } else { mForegroundPaddingLeft = 0; mForegroundPaddingTop = 0; mForegroundPaddingRight = 0; mForegroundPaddingBottom = 0; } requestLayout(); } }
Example 8
Source File: ForegroundDelegate.java From ForegroundViews with Apache License 2.0 | 6 votes |
public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); mForeground.getPadding(padding); } mView.requestLayout(); } }
Example 9
Source File: ForegroundDelegate.java From ForegroundViews with Apache License 2.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child * views in the frame layout. Any padding in the Drawable will be taken * into account by ensuring that the children are inset to be placed * inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ public void setForeground(@Nullable Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); mView.unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { mView.setWillNotDraw(false); drawable.setCallback(mView); if (drawable.isStateful()) { drawable.setState(mView.getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { mView.setWillNotDraw(true); } mView.requestLayout(); mView.invalidate(); } }
Example 10
Source File: ForegroundCheckTextView.java From MaterialPreference with Apache License 2.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child * views in the frame layout. Any padding in the Drawable will be taken * into account by ensuring that the children are inset to be placed * inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ public void setForeground(Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
Example 11
Source File: ForegroundLinearLayout.java From android-proguards with Apache License 2.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child * views in this layout. Any padding in the Drawable will be taken * into account by ensuring that the children are inset to be placed * inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ public void setForeground(Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
Example 12
Source File: ForegroundLinearLayout.java From material-components-android with Apache License 2.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child views in the frame layout. * Any padding in the Drawable will be taken into account by ensuring that the children are inset * to be placed inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ @Override public void setForeground(@Nullable Drawable drawable) { if (foreground != drawable) { if (foreground != null) { foreground.setCallback(null); unscheduleDrawable(foreground); } foreground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (foregroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
Example 13
Source File: FrameLayoutCompat.java From Mover with Apache License 2.0 | 5 votes |
/** * Describes how the foreground is positioned. Defaults to START and TOP. * * @param foregroundGravity See {@link android.view.Gravity} * * @see #getForegroundGravity() * * @attr ref android.R.styleable#FrameLayout_foregroundGravity */ public void setForegroundGravity(int foregroundGravity) { if (mForegroundGravity != foregroundGravity) { if ((foregroundGravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.START; } if ((foregroundGravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { foregroundGravity |= Gravity.TOP; } mForegroundGravity = foregroundGravity; if (mForegroundGravity == Gravity.FILL && mForeground != null) { Rect padding = new Rect(); if (mForeground.getPadding(padding)) { mForegroundPaddingLeft = padding.left; mForegroundPaddingTop = padding.top; mForegroundPaddingRight = padding.right; mForegroundPaddingBottom = padding.bottom; } } else { mForegroundPaddingLeft = 0; mForegroundPaddingTop = 0; mForegroundPaddingRight = 0; mForegroundPaddingBottom = 0; } requestLayout(); } }
Example 14
Source File: LayoutBase.java From tns-core-modules-widgets with Apache License 2.0 | 5 votes |
protected static int getGravity(View view) { int gravity = -1; LayoutParams params = view.getLayoutParams(); if (params instanceof FrameLayout.LayoutParams) { gravity = ((FrameLayout.LayoutParams)params).gravity; } if (gravity == -1) { gravity = Gravity.FILL; } return gravity; }
Example 15
Source File: ForegroundDelegate.java From VideoOS-Android-SDK with GNU General Public License v3.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child * views in the frame layout. Any padding in the Drawable will be taken * into account by ensuring that the children are inset to be placed * inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ public void setForeground(View view, Drawable drawable) { if (view != null) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); view.unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { view.setWillNotDraw(false); drawable.setCallback(view); if (drawable.isStateful()) { drawable.setState(view.getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } //update bounds updateBounds(view, drawable);//added by song } else { view.setWillNotDraw(true); } view.requestLayout(); view.invalidate(); } } }
Example 16
Source File: ForegroundLinearLayout.java From Mizuu with Apache License 2.0 | 5 votes |
/** * Supply a Drawable that is to be rendered on top of all of the child * views in the frame layout. Any padding in the Drawable will be taken * into account by ensuring that the children are inset to be placed * inside of the padding area. * * @param drawable The Drawable to be drawn on top of the children. */ public void setForeground(Drawable drawable) { if (mForeground != drawable) { if (mForeground != null) { mForeground.setCallback(null); unscheduleDrawable(mForeground); } mForeground = drawable; if (drawable != null) { setWillNotDraw(false); drawable.setCallback(this); if (drawable.isStateful()) { drawable.setState(getDrawableState()); } if (mForegroundGravity == Gravity.FILL) { Rect padding = new Rect(); drawable.getPadding(padding); } } else { setWillNotDraw(true); } requestLayout(); invalidate(); } }
Example 17
Source File: TextViewParser.java From pandora with Apache License 2.0 | 5 votes |
private static String gravityToStr(int gravity) { switch (gravity) { case Gravity.NO_GRAVITY: return "NO_GRAVITY"; case Gravity.LEFT: return "LEFT"; case Gravity.TOP: return "TOP"; case Gravity.RIGHT: return "RIGHT"; case Gravity.BOTTOM: return "BOTTOM"; case Gravity.CENTER: return "CENTER"; case Gravity.CENTER_HORIZONTAL: return "CENTER_HORIZONTAL"; case Gravity.CENTER_VERTICAL: return "CENTER_VERTICAL"; case Gravity.START: return "START"; case Gravity.END: return "END"; case Gravity.CLIP_HORIZONTAL: return "CLIP_HORIZONTAL"; case Gravity.CLIP_VERTICAL: return "CLIP_VERTICAL"; case Gravity.FILL: return "FILL"; case Gravity.FILL_HORIZONTAL: return "FILL_HORIZONTAL"; case Gravity.FILL_VERTICAL: return "FILL_VERTICAL"; default: return "OTHER"; } }
Example 18
Source File: SimpleArgumentsBundle.java From Rhythm with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} Does a quick and rough parsing of the raw string for containing constant words like * <code>top</code> or <code>center_vertical</code> */ @Override @SuppressLint("RtlHardcoded") public int getGravity(String key, int defaultValue) { String gravityArg = resolveArgument(key); if (gravityArg == null) { return defaultValue; } else if (gravityArg.equals("center")) { return Gravity.CENTER; } else if (gravityArg.equals("fill")) { return Gravity.FILL; } else { // supported options int gravity = 0; if (gravityArg.contains("top")) { gravity |= Gravity.TOP; } if (gravityArg.contains("bottom")) { gravity |= Gravity.BOTTOM; } if (gravityArg.contains("center_vertical")) { gravity |= Gravity.CENTER_VERTICAL; } if (gravityArg.contains("fill_vertical")) { gravity |= Gravity.FILL_VERTICAL; } if (gravityArg.contains("left")) { gravity |= Gravity.LEFT; } if (gravityArg.contains("right")) { gravity |= Gravity.RIGHT; } if (gravityArg.contains("center_horizontal")) { gravity |= Gravity.CENTER_HORIZONTAL; } if (gravityArg.contains("fill_horizontal")) { gravity |= Gravity.FILL_HORIZONTAL; } return gravity; } }
Example 19
Source File: TagTabStrip.java From ProjectX with Apache License 2.0 | 4 votes |
@SuppressLint("RtlHardcoded") private void applyGravity(int itemWidth, int itemHeight) { final int count = mCount; if (count == 0) { mFirstCenterX = 0; mFirstCenterY = 0; mItemCenterOffset = 0; return; } final int padding = mPadding; final float scale = mScale > 1 ? mScale : 1; final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingEnd = ViewCompat.getPaddingEnd(this); final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); final int contentWidth = width - paddingStart - paddingEnd; final int contentHeight = height - paddingTop - paddingBottom; mItemCenterOffset = itemWidth + padding; switch (GravityCompat.getAbsoluteGravity(mGravity, ViewCompat.getLayoutDirection(this))) { case Gravity.LEFT: case Gravity.TOP: case Gravity.LEFT | Gravity.TOP: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.CENTER_HORIZONTAL: case Gravity.CENTER_HORIZONTAL | Gravity.TOP: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.RIGHT: case Gravity.RIGHT | Gravity.TOP: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.CENTER_VERTICAL: case Gravity.CENTER_VERTICAL | Gravity.LEFT: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; default: case Gravity.CENTER: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.CENTER_VERTICAL | Gravity.RIGHT: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.BOTTOM: case Gravity.BOTTOM | Gravity.LEFT: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; case Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; case Gravity.RIGHT | Gravity.BOTTOM: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; // 水平方向上沾满 case Gravity.FILL: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.FILL_HORIZONTAL: case Gravity.FILL_HORIZONTAL | Gravity.TOP: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.FILL_HORIZONTAL | Gravity.BOTTOM: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; } }
Example 20
Source File: CommonLayoutParams.java From tns-core-modules-widgets with Apache License 2.0 | 4 votes |
public CommonLayoutParams() { super(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.FILL); }