android.view.Gravity#isVertical ( )源码实例Demo

下面列出了android.view.Gravity#isVertical ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: CameraV   文件: VerticalButton.java
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();
}
 
源代码2 项目: LaunchEnr   文件: PopupContainerWithArrow.java
/**
 * 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;
}
 
源代码3 项目: AssistantBySDK   文件: VerticalTextView.java
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;
    }
}
 
源代码4 项目: Kandroid   文件: VerticalTextView.java
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;
}
 
源代码5 项目: Kandroid   文件: VerticalTextView.java
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;
}
 
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;
}
 
源代码7 项目: journaldev   文件: VerticalTextView.java
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;

}
 
源代码8 项目: Blackbulb   文件: VerticalTextView.java
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;
    }
}
 
源代码9 项目: date_picker_converter   文件: VerticalTextView.java
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;
    }
}
 
源代码10 项目: Carbon   文件: LayerDrawable.java
/**
 * 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;
}
 
源代码11 项目: MaterialDateTimePicker   文件: VerticalTextView.java
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;
    }
}
 
源代码12 项目: SwipeBack   文件: VerticalTextView.java
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;
}
 
源代码13 项目: SlideLayout   文件: VerticalButton.java
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;
}