ALIGN_PARENT_TOP源码实例Demo

android.widget.RelativeLayout#ALIGN_PARENT_TOP源码实例Demo

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

源代码1 项目: godot_modules   文件: GodotAdMob.java
public void SetBannerTopLeft()
{
	if (!initialized) return;

	if (layoutRule1 != RelativeLayout.ALIGN_PARENT_TOP || 
		layoutRule2 != RelativeLayout.ALIGN_PARENT_LEFT)
	{
		activity.runOnUiThread(new Runnable() {
			public void run() {
				layoutRule1 = RelativeLayout.ALIGN_PARENT_TOP; 
				layoutRule2 = RelativeLayout.ALIGN_PARENT_LEFT;
				
				Log.d("godot", "AdMob: Moving Banner to top left");
				
				if (adView != null)
				{
					SetBannerView();
				}
			}
		});
	}
}
 
源代码2 项目: appcan-android   文件: EUExBase.java
protected final void adptLayoutParams(RelativeLayout.LayoutParams rParms,
                                      FrameLayout.LayoutParams outParm) {
    if (null == rParms) {
        return;
    }
    int TRUE = RelativeLayout.TRUE;
    int ALIGN_PARENT_LEFT = RelativeLayout.ALIGN_PARENT_LEFT;
    int ALIGN_PARENT_TOP = RelativeLayout.ALIGN_PARENT_TOP;
    int ALIGN_PARENT_RIGHT = RelativeLayout.ALIGN_PARENT_RIGHT;
    int ALIGN_PARENT_BOTTOM = RelativeLayout.ALIGN_PARENT_BOTTOM;
    int CENTER_IN_PARENT = RelativeLayout.CENTER_IN_PARENT;
    int CENTER_HORIZONTAL = RelativeLayout.CENTER_HORIZONTAL;
    int CENTER_VERTICAL = RelativeLayout.CENTER_VERTICAL;
    try {
        int[] rules = rParms.getRules();
        if (rules[ALIGN_PARENT_LEFT] == TRUE) {
            outParm.gravity |= Gravity.LEFT;
        }
        if (rules[ALIGN_PARENT_TOP] == TRUE) {
            outParm.gravity |= Gravity.TOP;
        }
        if (rules[ALIGN_PARENT_RIGHT] == TRUE) {
            outParm.gravity |= Gravity.RIGHT;
        }
        if (rules[ALIGN_PARENT_BOTTOM] == TRUE) {
            outParm.gravity |= Gravity.BOTTOM;
        }
        if (rules[CENTER_IN_PARENT] == TRUE) {
            outParm.gravity |= Gravity.CENTER;
        }
        if (rules[CENTER_HORIZONTAL] == TRUE) {
            outParm.gravity |= Gravity.CENTER_HORIZONTAL;
        }
        if (rules[CENTER_VERTICAL] == TRUE) {
            outParm.gravity |= Gravity.CENTER_VERTICAL;
        }
    } catch (Exception e) {
        ;
    }
}
 
源代码3 项目: hintcase   文件: HintCaseView.java
@NonNull
private FrameLayout getHintBlockFrameLayout() {
    int blockWidth = 0;
    int blockHeight = 0;
    int blockAlign = 0;
    switch (hintBlockPosition) {
        case HintCase.HINT_BLOCK_POSITION_TOP:
            blockWidth = parent.getWidth();
            blockHeight = shape.getTop()
                    - parent.getTop()
                    - DimenUtils.getStatusBarHeight(getContext());
            blockAlign = RelativeLayout.ALIGN_PARENT_TOP;
            break;
        case HintCase.HINT_BLOCK_POSITION_BOTTOM:
            blockWidth = parent.getWidth();
            blockHeight = parent.getBottom()
                    - navigationBarSizeIfExistAtTheBottom.y
                    - shape.getBottom();
            blockAlign = RelativeLayout.ALIGN_PARENT_BOTTOM;
            break;
        case HintCase.HINT_BLOCK_POSITION_LEFT:
            blockWidth = shape.getLeft() - parent.getLeft();
            blockHeight = parent.getHeight() - DimenUtils.getStatusBarHeight(getContext());
            blockAlign = RelativeLayout.ALIGN_PARENT_LEFT;
            break;
        case HintCase.HINT_BLOCK_POSITION_RIGHT:
            blockWidth = parent.getRight()
                    - navigationBarSizeIfExistOnTheRight.x
                    - shape.getRight();
            blockHeight = parent.getHeight() - DimenUtils.getStatusBarHeight(getContext());
            blockAlign = RelativeLayout.ALIGN_PARENT_RIGHT;
            break;
        case HintCase.HINT_BLOCK_POSITION_CENTER:
            blockWidth = parent.getWidth() - navigationBarSizeIfExistOnTheRight.x;
            blockHeight = parent.getHeight()
                    - navigationBarSizeIfExistAtTheBottom.y
                    - DimenUtils.getStatusBarHeight(getContext());
            blockAlign = RelativeLayout.ALIGN_PARENT_BOTTOM;
            break;

    }
    LayoutParams relativeLayoutParams =
            new LayoutParams(blockWidth, blockHeight);
    relativeLayoutParams.addRule(blockAlign);
    relativeLayoutParams.topMargin = DimenUtils.getStatusBarHeight(getContext());
    relativeLayoutParams.bottomMargin = navigationBarSizeIfExistAtTheBottom.y;
    relativeLayoutParams.rightMargin = navigationBarSizeIfExistOnTheRight.x;
    FrameLayout frameLayout = new FrameLayout(getContext());
    frameLayout.setLayoutParams(relativeLayoutParams);
    return frameLayout;
}