android.widget.RelativeLayout.LayoutParams#addRule ( )源码实例Demo

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

源代码1 项目: FimiX8-RE   文件: CustomVideoView.java
private void initView() {
    this.mPlayerView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.album_custom_video_view, this);
    this.mPlayerView.setOnClickListener(this);
    this.mLoadingBar = (ProgressBar) this.mPlayerView.findViewById(R.id.load_iv);
    this.mVideoView = (TextureView) this.mPlayerView.findViewById(R.id.play_video_textureview);
    this.mVideoView.setOnClickListener(this);
    this.mVideoView.setKeepScreenOn(true);
    this.mVideoView.setSurfaceTextureListener(this);
    this.mTopBarLl = (LinearLayout) this.mPlayerView.findViewById(R.id.shoto_top_tab_ll);
    this.mBottomPlayRl = (RelativeLayout) this.mPlayerView.findViewById(R.id.bottom_play_rl);
    this.mMiniPlayBtn = (ImageButton) this.mBottomPlayRl.findViewById(R.id.play_btn);
    this.mPlaySb = (SeekBar) this.mBottomPlayRl.findViewById(R.id.play_sb);
    this.mPlaySb.setOnSeekBarChangeListener(this);
    this.mMiniPlayBtn.setOnClickListener(this);
    this.mCurrentTimeTv = (TextView) this.mBottomPlayRl.findViewById(R.id.time_current_tv);
    this.mTotalTimeTv = (TextView) this.mBottomPlayRl.findViewById(R.id.total_time_tv);
    showBar(false);
    this.nameTv = (TextView) findViewById(R.id.photo_name_tv);
    this.mPlayBackIBtn = (ImageButton) findViewById(R.id.media_back_btn);
    this.mPlayBackIBtn.setOnClickListener(this);
    this.mPlayerView.setOnClickListener(this);
    LayoutParams params = new LayoutParams(this.mScreenWidth, this.mDestationHeight);
    params.addRule(13);
    this.mPlayerView.setLayoutParams(params);
}
 
源代码2 项目: FimiX8-RE   文件: X8CustomVideoView.java
private void initView() {
    this.mPlayerView = (RelativeLayout) LayoutInflater.from(getContext()).inflate(R.layout.x8_custom_video_view, this);
    this.mPlayerView.setOnClickListener(this);
    this.mLoadingBar = (ProgressBar) this.mPlayerView.findViewById(R.id.load_iv);
    this.mVideoView = (TextureView) this.mPlayerView.findViewById(R.id.play_video_textureview);
    this.mBtnPlayMax = (Button) this.mPlayerView.findViewById(R.id.btn_play_max);
    this.mBtnPlayMax.setOnClickListener(this);
    this.mVideoView.setOnClickListener(this);
    this.mVideoView.setKeepScreenOn(true);
    this.mVideoView.setSurfaceTextureListener(this);
    this.mBottomPlayRl = (RelativeLayout) this.mPlayerView.findViewById(R.id.bottom_play_rl);
    this.mMiniPlayBtn = (ImageButton) this.mBottomPlayRl.findViewById(R.id.play_btn);
    this.mPlaySb = (SeekBar) this.mBottomPlayRl.findViewById(R.id.play_sb);
    this.mPlaySb.setOnSeekBarChangeListener(this);
    this.mMiniPlayBtn.setOnClickListener(this);
    this.mCurrentTimeTv = (TextView) this.mBottomPlayRl.findViewById(R.id.time_current_tv);
    this.mCurrentTimeTv.setText(setTimeFormatter(0));
    this.mTotalTimeTv = (TextView) this.mBottomPlayRl.findViewById(R.id.total_time_tv);
    this.mTotalTimeTv.setText(this.mTotalTime);
    showBar(true);
    this.mPlayerView.setOnClickListener(this);
    LayoutParams params = new LayoutParams(this.mScreenWidth, this.mDestationHeight);
    params.addRule(13);
    this.mPlayerView.setLayoutParams(params);
    FontUtil.changeFontLanTing(getResources().getAssets(), this.mTotalTimeTv, this.mCurrentTimeTv);
}
 
源代码3 项目: douyin   文件: InfoAdapter.java
@Override
public View onCreateView(LayoutInflater layoutInflater, ViewGroup parent, int viewType) {
    RelativeLayout layout = new RelativeLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, dp2px(45));
    layout.setLayoutParams(layoutParams);

    TextView title = new TextView(getContext());
    title.setId(0);
    LayoutParams title_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    title_params.addRule(RelativeLayout.CENTER_VERTICAL);
    title_params.setMargins(dp2px(18), 0, 0, 0);
    title.setLayoutParams(title_params);

    TextView subTitle = new TextView(getContext());
    subTitle.setId(1);
    LayoutParams subTitle_params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    subTitle_params.addRule(RelativeLayout.CENTER_VERTICAL);
    subTitle_params.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    subTitle_params.setMargins(0, 0, dp2px(20), 0);
    subTitle.setLayoutParams(subTitle_params);

    layout.addView(title);
    layout.addView(subTitle);
    return layout;
}
 
源代码4 项目: PanoramaGL   文件: PLView.java
/**
    * This event is fired when GLSurfaceView is created
    * @param glSurfaceView current GLSurfaceView
    */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView)
{
	for(int i = 0; i < kMaxTouches; i++)
		mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
	mContentLayout = new RelativeLayout(this);
	mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
	LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	mProgressBar = new ProgressBar(this);
	mProgressBar.setIndeterminate(true);
	mProgressBar.setVisibility(View.GONE);
	mContentLayout.addView(mProgressBar, progressBarLayoutParams);
	return this.onContentViewCreated(mContentLayout);
}
 
源代码5 项目: CoreModule   文件: BrowserDelegate.java
@Override
public void initWidget() {
    super.initWidget();
    webView = get(R.id.webview);
    mLayoutBottom = (LinearLayout) View.inflate(getActivity(),
            R.layout.item_browser_bottombar, null);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams
            .WRAP_CONTENT);
    params.leftMargin = 60;
    params.rightMargin = 60;
    params.bottomMargin = 30;
    params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
    ((RelativeLayout) get(R.id.browser_root)).addView(mLayoutBottom, 1, params);
    mLayoutBottom.setVisibility(View.GONE);

    new BrowserDelegateOption(this, linkDispatcher).initWebView();
}
 
源代码6 项目: AndroidAnimationExercise   文件: PopupManager.java
public static void showPopupWon(GameState gameState) {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// popup
	PopupWonView popupWonView = new PopupWonView(Shared.context);
	popupWonView.setGameState(gameState);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_won_height);
	LayoutParams params = new LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupWonView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupWonView, "scaleY", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	popupWonView.setLayerType(View.LAYER_TYPE_HARDWARE, null);
	animatorSet.start();
}
 
源代码7 项目: panoramagl   文件: PLManager.java
/**
 * This event is fired when GLSurfaceView is created
 *
 * @param glSurfaceView current GLSurfaceView
 */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) {
    for (int i = 0; i < kMaxTouches; i++)
        mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
    mContentLayout = new RelativeLayout(context);
    mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar = new ProgressBar(context);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);
    mContentLayout.addView(mProgressBar, progressBarLayoutParams);
    return this.onContentViewCreated(mContentLayout);
}
 
源代码8 项目: panoramagl   文件: PLView.java
/**
 * This event is fired when GLSurfaceView is created
 *
 * @param glSurfaceView current GLSurfaceView
 */
@SuppressWarnings("deprecation")
protected View onGLSurfaceViewCreated(GLSurfaceView glSurfaceView) {
    for (int i = 0; i < kMaxTouches; i++)
        mInternalTouches.add(new UITouch(glSurfaceView, new CGPoint(0.0f, 0.0f)));
    mContentLayout = new RelativeLayout(this);
    mContentLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    mContentLayout.addView(glSurfaceView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
    LayoutParams progressBarLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    progressBarLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.GONE);
    mContentLayout.addView(mProgressBar, progressBarLayoutParams);
    return this.onContentViewCreated(mContentLayout);
}
 
源代码9 项目: CuXtomCam   文件: CuxtomCamActivity.java
/**
 * initialize video recording UI with timer
 */
private void initVideoRecordingUI(String initializeTime) {
	LayoutParams rl_param = new LayoutParams(
			android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
			android.view.ViewGroup.LayoutParams.WRAP_CONTENT);
	rl_param.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	rl_param.addRule(RelativeLayout.CENTER_HORIZONTAL);
	rl_param.addRule(RelativeLayout.ALIGN_BOTTOM, mPreview.getId());
	rl_param.setMargins(0, 0, 0, 30);
	tv_recordingDuration.setText(initializeTime);
	tv_recordingDuration.setTextSize(28);
	tv_recordingDuration.setLayoutParams(rl_param);
	previewCameraLayout.addView(tv_recordingDuration);
	mExecutorService = Executors.newSingleThreadScheduledExecutor();
	totalVideoDuration = 0;
	mExecutorService.scheduleAtFixedRate(recordingTimer, 1, 1,
			TimeUnit.SECONDS);
}
 
源代码10 项目: FimiX8-RE   文件: BodyRecycleViewHolder.java
private void initImageViewParams(Context context, View parentView, View view) {
    parentView.measure(0, 0);
    int currentHeight = parentView.getMeasuredHeight();
    LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
    layoutParams.addRule(11);
    layoutParams.rightMargin = SizeTool.pixToDp(12.0f, context);
    layoutParams.topMargin = currentHeight - SizeTool.pixToDp(25.0f, context);
    view.setLayoutParams(layoutParams);
}
 
源代码11 项目: FimiX8-RE   文件: BodyRecycleViewHolder.java
private void initImageViewParams(Context context, View parentView, View view) {
    parentView.measure(0, 0);
    int currentHeight = parentView.getMeasuredHeight();
    LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
    layoutParams.addRule(11);
    layoutParams.rightMargin = SizeTool.pixToDp(12.0f, context);
    layoutParams.topMargin = currentHeight - SizeTool.pixToDp(25.0f, context);
    view.setLayoutParams(layoutParams);
}
 
源代码12 项目: RePlugin-GameSdk   文件: FunRegistActivity.java
@Override
protected void onPreExecute() {
	super.onPreExecute();
	registProgressBar = new ProgressBar(FunRegistActivity.this, null,
			android.R.attr.progressBarStyle);
	registProgressBar.setVisibility(View.VISIBLE);

	LayoutParams progressBarParams = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	registRelativeLayout.addView(registProgressBar, progressBarParams);
}
 
源代码13 项目: RePlugin-GameSdk   文件: FunLoginActivity.java
@Override
protected void onPreExecute() {
	super.onPreExecute();
	loginProgressBar = new ProgressBar(FunLoginActivity.this, null,
			android.R.attr.progressBarStyle);
	loginProgressBar.setVisibility(View.VISIBLE);

	LayoutParams progressBarParams = new LayoutParams(
			LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	progressBarParams.addRule(RelativeLayout.CENTER_IN_PARENT);
	loginRelativeLayout.addView(loginProgressBar, progressBarParams);
}
 
源代码14 项目: letv   文件: PlayLoadLayout.java
public void initWithNonCopyright() {
    this.mIsNonCopyright = true;
    r4 = new int[2][];
    r4[0] = new int[]{16842919};
    r4[1] = new int[0];
    ColorStateList color = new ColorStateList(r4, new int[]{-1, this.mContext.getResources().getColor(R.color.letv_color_noncopyright)});
    int bg = R.drawable.noncopyright_btn_selector;
    this.request_error_btn.setTextColor(color);
    this.complaint_success_button.setTextColor(color);
    this.vip_not_login_error_btn.setTextColor(color);
    this.vip_login_error_btn.setTextColor(color);
    this.jump_error_btn.setTextColor(color);
    this.demand_error_btn.setTextColor(color);
    this.cannot_play_btn.setTextColor(color);
    this.mTxtSubmitInfo.setTextColor(color);
    this.ip_error_call_text.setTextColor(color);
    this.request_error_btn.setBackgroundResource(bg);
    this.complaint_success_button.setBackgroundResource(bg);
    this.vip_not_login_error_btn.setBackgroundResource(bg);
    this.vip_login_error_btn.setBackgroundResource(bg);
    this.jump_error_btn.setBackgroundResource(bg);
    this.demand_error_btn.setBackgroundResource(bg);
    this.cannot_play_btn.setBackgroundResource(bg);
    this.ip_error_call_text.setBackgroundResource(bg);
    int visibile = this.loading.getVisibility();
    findViewById(R.id.loading).setVisibility(8);
    this.loading = findViewById(R.id.noncopyright_loading);
    this.loading.setVisibility(visibile);
    LayoutParams lp = (LayoutParams) this.loadingTxt.getLayoutParams();
    lp.addRule(3, R.id.noncopyright_loading);
    this.loadingTxt.setLayoutParams(lp);
    this.mTxtSubmitInfo.setVisibility(8);
}
 
源代码15 项目: letv   文件: LivePlayerView.java
private void initVideoView() {
    if (this.mVideoView == null) {
        this.mVideoView = new LiveVideoView(this.mContext);
        this.mVideoView.setStatisticsHelper(this.mStatisticsHelper);
        LayoutParams params = new LayoutParams(-1, -1);
        params.addRule(13);
        addView(this.mVideoView, params);
    }
}
 
源代码16 项目: AndroidAnimationExercise   文件: PopupManager.java
public static void showPopupSettings() {
	RelativeLayout popupContainer = (RelativeLayout) Shared.activity.findViewById(R.id.popup_container);
	popupContainer.removeAllViews();

	// background
	ImageView imageView = new ImageView(Shared.context);
	imageView.setBackgroundColor(Color.parseColor("#88555555"));
	imageView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
	imageView.setClickable(true);
	popupContainer.addView(imageView);

	// popup
	PopupSettingsView popupSettingsView = new PopupSettingsView(Shared.context);
	int width = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_width);
	int height = Shared.context.getResources().getDimensionPixelSize(R.dimen.popup_settings_height);
	LayoutParams params = new LayoutParams(width, height);
	params.addRule(RelativeLayout.CENTER_IN_PARENT);
	popupContainer.addView(popupSettingsView, params);

	// animate all together
	ObjectAnimator scaleXAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleX", 0f, 1f);
	ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(popupSettingsView, "scaleY", 0f, 1f);
	ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(imageView, "alpha", 0f, 1f);
	AnimatorSet animatorSet = new AnimatorSet();
	animatorSet.playTogether(scaleXAnimator, scaleYAnimator, alphaAnimator);
	animatorSet.setDuration(500);
	animatorSet.setInterpolator(new DecelerateInterpolator(2));
	animatorSet.start();
}
 
源代码17 项目: Mi-Band   文件: ColorPickerDialog.java
public ColorPickerDialog(Context context, int initialColor, final OnColorSelectedListener onColorSelectedListener) {
    super(context);

    RelativeLayout relativeLayout = new RelativeLayout(context);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    colorPickerView = new ColorPicker(context);
    colorPickerView.setColor(initialColor);

    relativeLayout.addView(colorPickerView, layoutParams);

    OnClickListener onClickListener = new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            switch (which) {
                case BUTTON_POSITIVE:
                    int selectedColor = colorPickerView.getColor();
                    onColorSelectedListener.onColorSelected(selectedColor);
                    break;
                case BUTTON_NEGATIVE:
                    dialog.dismiss();
                    break;
            }
        }

    };
    setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), onClickListener);
    setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), onClickListener);

    setView(relativeLayout);

}
 
源代码18 项目: Android-Color-Picker   文件: ColorPickerDialog.java
public ColorPickerDialog(Context context, int initialColor, OnColorSelectedListener onColorSelectedListener) {
    super(context);

    this.onColorSelectedListener = onColorSelectedListener;

    RelativeLayout relativeLayout = new RelativeLayout(context);
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    colorPickerView = new ColorPicker(context);
    colorPickerView.setColor(initialColor);

    relativeLayout.addView(colorPickerView, layoutParams);

    setButton(BUTTON_POSITIVE, context.getString(android.R.string.ok), onClickListener);
    setButton(BUTTON_NEGATIVE, context.getString(android.R.string.cancel), onClickListener);

    setView(relativeLayout);

}
 
源代码19 项目: Auie   文件: UIImagePager.java
/**
 * 初始化控件
 */
private View createContentView() {
	
	rootContainer = new RelativeLayout(context);
	rootContainer.setBackgroundColor(Color.parseColor("#000000"));
	rootContainer.setLayoutParams(new LayoutParams(MATCH_PARENT, MATCH_PARENT));
	
	LayoutParams contentParams = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
	contentParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
	contentContainer = new ViewPager(context);
	contentContainer.setAdapter(imageAdapter);
	contentContainer.setLayoutParams(contentParams);
	contentContainer.setOnPageChangeListener(onPageChangeListener);
	
	LayoutParams params = new LayoutParams(MATCH_PARENT, WRAP_CONTENT);
	params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
	indexContainer = new LinearLayout(context);
	indexContainer.setLayoutParams(params);
	indexContainer.setPadding(0, 0, 0, DP * 20);
	indexContainer.setGravity(Gravity.CENTER);
	indexContainer.setOrientation(LinearLayout.HORIZONTAL);
	
	LayoutParams params2 = new LayoutParams(60 * DP, 32 * DP);
	params2.addRule(RelativeLayout.ALIGN_PARENT_LEFT, RelativeLayout.TRUE);
	params2.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
	params2.setMargins(10 * DP, 0, 0, 10 * DP);
	actionButton = new UIButton(context);
	actionButton.setLayoutParams(params2);
	actionButton.setText("删除");
	actionButton.setTextSize(14);
	actionButton.setVisibility(View.GONE);
	actionButton.setTextColor(Color.WHITE);
	actionButton.setBackgroundColor(Color.RED);
	actionButton.setOnClickListener(onClickListener);
	
	rootContainer.addView(contentContainer);
	rootContainer.addView(indexContainer);
	rootContainer.addView(actionButton);
	
	return rootContainer;
}
 
@Override
protected View onCreateDialogView() {

    RelativeLayout relativeLayout = new RelativeLayout(getContext());
    LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);

    colorPickerView = new ColorPicker(getContext());
    colorPickerView.setId(1);

    relativeLayout.addView(colorPickerView, layoutParams);

    return relativeLayout;

}