RelativeLayout addView LEFT_TO Center View,然后Center View不在中心了,为什么?

RelativeLayout addView LEFT_TO Center View,Then the Center View doesn`t still in the center,why?

如题,图片如下

代码:

textView = new TextView(mContext);
textView.setId(5005);
textView.setText(mShareText);
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mShareTextSize);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params.alignWithParent = true;
params.addRule(CENTER_IN_PARENT, TRUE);
addView(textView, params);

imageView = new ImageView(mContext);
initImageView();
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
params2.addRule(LEFT_OF, 5005);
params2.addRule(CENTER_VERTICAL, TRUE);
params2.rightMargin = mDrawablePaddingDP;
addView(imageView, params2);

setControlAble();

这是扩展 RelativeLayout 的自定义视图。 我想让M还在中间,程序留给M,怎么办?

再创建一个文本视图,为其指定一个 ID 并将文本设置为“ ”(space 或空白)。现在把它放在中间。现在您可以将图像和文本视图设置为 it.Best 运气。