Java Code Examples for android.widget.RelativeLayout.LayoutParams#addRule()

The following examples show how to use android.widget.RelativeLayout.LayoutParams#addRule() . 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: CustomVideoView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
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);
}
 
Example 2
Source File: CuxtomCamActivity.java    From CuXtomCam with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source File: PLView.java    From panoramagl with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 4
Source File: PLManager.java    From panoramagl with Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source File: PopupManager.java    From AndroidAnimationExercise with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 6
Source File: BrowserDelegate.java    From CoreModule with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example 7
Source File: PLView.java    From PanoramaGL with Apache License 2.0 6 votes vote down vote up
/**
    * 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);
}
 
Example 8
Source File: InfoAdapter.java    From douyin with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 9
Source File: X8CustomVideoView.java    From FimiX8-RE with MIT License 6 votes vote down vote up
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);
}
 
Example 10
Source File: PlayLoadLayout.java    From letv with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 11
Source File: LivePlayerView.java    From letv with Apache License 2.0 5 votes vote down vote up
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);
    }
}
 
Example 12
Source File: FunLoginActivity.java    From RePlugin-GameSdk with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 13
Source File: PopupManager.java    From AndroidAnimationExercise with Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 14
Source File: FunRegistActivity.java    From RePlugin-GameSdk with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example 15
Source File: ColorPickerDialog.java    From Mi-Band with GNU General Public License v2.0 5 votes vote down vote up
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);

}
 
Example 16
Source File: BodyRecycleViewHolder.java    From FimiX8-RE with MIT License 5 votes vote down vote up
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);
}
 
Example 17
Source File: BodyRecycleViewHolder.java    From FimiX8-RE with MIT License 5 votes vote down vote up
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);
}
 
Example 18
Source File: ColorPickerDialog.java    From Android-Color-Picker with Apache License 2.0 4 votes vote down vote up
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);

}
 
Example 19
Source File: UIImagePager.java    From Auie with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 初始化控件
 */
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;
}
 
Example 20
Source File: ColorPickerPreference.java    From Android-Color-Picker with Apache License 2.0 3 votes vote down vote up
@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;

}