Java Code Examples for android.view.Gravity#isVertical()
The following examples show how to use
android.view.Gravity#isVertical() .
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: VerticalButton.java From CameraV with GNU General Public License v3.0 | 6 votes |
public VerticalButton(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); } setPadding(0, 20, 0, 0); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.VerticalButton); CharSequence s = a.getString(R.styleable.VerticalButton_android_text); if(s != null) setText(s.toString()); a.recycle(); }
Example 2
Source File: PopupContainerWithArrow.java From LaunchEnr with GNU General Public License v3.0 | 5 votes |
/** * Adds an arrow view pointing at the original icon. * @param horizontalOffset the horizontal offset of the arrow, so that it * points at the center of the original icon */ private View addArrowView(int horizontalOffset, int verticalOffset, int width, int height) { LayoutParams layoutParams = new LayoutParams(width, height); if (mIsLeftAligned) { layoutParams.gravity = Gravity.START; layoutParams.leftMargin = horizontalOffset; } else { layoutParams.gravity = Gravity.END; layoutParams.rightMargin = horizontalOffset; } if (mIsAboveIcon) { layoutParams.topMargin = verticalOffset; } else { layoutParams.bottomMargin = verticalOffset; } View arrowView = new View(getContext()); if (Gravity.isVertical(((FrameLayout.LayoutParams) getLayoutParams()).gravity)) { // This is only true if there wasn't room for the container next to the icon, // so we centered it instead. In that case we don't want to show the arrow. arrowView.setVisibility(INVISIBLE); } else { ShapeDrawable arrowDrawable = new ShapeDrawable(TriangleShape.create( width, height, !mIsAboveIcon)); Paint arrowPaint = arrowDrawable.getPaint(); // Note that we have to use getChildAt() instead of getItemViewAt(), // since the latter expects the arrow which hasn't been added yet. PopupItemView itemAttachedToArrow = (PopupItemView) (getChildAt(mIsAboveIcon ? getChildCount() - 1 : 0)); arrowPaint.setColor(itemAttachedToArrow.getArrowColor(mIsAboveIcon)); // The corner path effect won't be reflected in the shadow, but shouldn't be noticeable. int radius = getResources().getDimensionPixelSize(R.dimen.popup_arrow_corner_radius); arrowPaint.setPathEffect(new CornerPathEffect(radius)); arrowView.setBackground(arrowDrawable); arrowView.setElevation(getElevation()); } addView(arrowView, mIsAboveIcon ? getChildCount() : 0, layoutParams); return arrowView; }
Example 3
Source File: VerticalTextView.java From AssistantBySDK with Apache License 2.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else { topDown = true; } }
Example 4
Source File: VerticalTextView.java From Kandroid with GNU General Public License v3.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; }else topDown = true; }
Example 5
Source File: VerticalTextView.java From Kandroid with GNU General Public License v3.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; }else topDown = true; }
Example 6
Source File: AVerticalTextView.java From Stylish-Widget-for-Android with Apache License 2.0 | 5 votes |
public AVerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity& Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; }else topDown = true; }
Example 7
Source File: VerticalTextView.java From journaldev with MIT License | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs) { super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else topDown = true; }
Example 8
Source File: VerticalTextView.java From Blackbulb with GNU General Public License v3.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else { topDown = true; } }
Example 9
Source File: VerticalTextView.java From date_picker_converter with Apache License 2.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else { topDown = true; } }
Example 10
Source File: LayerDrawable.java From Carbon with Apache License 2.0 | 5 votes |
/** * Resolves layer gravity given explicit gravity and dimensions. * <p/> * If the client hasn't specified a gravity but has specified an explicit dimension, defaults to * START or TOP. Otherwise, defaults to FILL to preserve legacy behavior. * * @param gravity layer gravity * @param width width of the layer if set, -1 otherwise * @param height height of the layer if set, -1 otherwise * @return the default gravity for the layer */ private static int resolveGravity(int gravity, int width, int height, int intrinsicWidth, int intrinsicHeight) { if (!Gravity.isHorizontal(gravity)) { if (width < 0) { gravity |= Gravity.FILL_HORIZONTAL; } else { gravity |= Gravity.START; } } if (!Gravity.isVertical(gravity)) { if (height < 0) { gravity |= Gravity.FILL_VERTICAL; } else { gravity |= Gravity.TOP; } } // If a dimension if not specified, either implicitly or explicitly, // force FILL for that dimension's gravity. This ensures that colors // are handled correctly and ensures backward compatibility. if (width < 0 && intrinsicWidth < 0) { gravity |= Gravity.FILL_HORIZONTAL; } if (height < 0 && intrinsicHeight < 0) { gravity |= Gravity.FILL_VERTICAL; } return gravity; }
Example 11
Source File: VerticalTextView.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if (Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; } else { topDown = true; } }
Example 12
Source File: VerticalTextView.java From SwipeBack with Apache License 2.0 | 5 votes |
public VerticalTextView(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity&Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity&Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = false; }else topDown = true; }
Example 13
Source File: VerticalButton.java From SlideLayout with GNU General Public License v2.0 | 5 votes |
public VerticalButton(Context context, AttributeSet attrs){ super(context, attrs); final int gravity = getGravity(); if(Gravity.isVertical(gravity) && (gravity & Gravity.VERTICAL_GRAVITY_MASK) == Gravity.BOTTOM) { setGravity((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) | Gravity.TOP); topDown = true; } else topDown = false; }