Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 添加子视图后调整相对布局的大小_Android_View_Android Relativelayout - Fatal编程技术网

Android 添加子视图后调整相对布局的大小

Android 添加子视图后调整相对布局的大小,android,view,android-relativelayout,Android,View,Android Relativelayout,我有一个扩展RelativeLayout的自定义视图。 在使用xml布局将其膨胀之后,我想向其添加另一个视图。 我想在现有视图的上方添加视图。 这似乎可行,但RelativeLayout不会自行调整大小。 看起来旧的内容会被覆盖,或者向下滚动 不可见 我通过以下方式创建自定义RelativeLayout: 公共类BottomBarEdit扩展了RelativeLayout{ private Context context; public BottomBarEdit(Context conte

我有一个扩展RelativeLayout的自定义视图。 在使用xml布局将其膨胀之后,我想向其添加另一个视图。 我想在现有视图的上方添加视图。 这似乎可行,但RelativeLayout不会自行调整大小。 看起来旧的内容会被覆盖,或者向下滚动 不可见

我通过以下方式创建自定义RelativeLayout:

公共类BottomBarEdit扩展了RelativeLayout{

private Context context;


public BottomBarEdit(Context context, AttributeSet attrs, int defStyle) {

    super(context, attrs, defStyle);
    this.context = context;

    View.inflate(context, R.layout.lay_bottom_bar_edit, this);
我尝试通过以下方式动态添加视图:

// create layout parameters
    RelativeLayout.LayoutParams lparams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.WRAP_CONTENT);
    lparams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    lparams.addRule(RelativeLayout.ALIGN_PARENT_TOP);
    lparams.addRule(RelativeLayout.ABOVE, R.id.bottom_bar_buttons);
    // RelativeLayout editMain = (RelativeLayout)
    // findViewById(R.id.bottom_bar_edit);

    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View noteBar = inflater.inflate(R.layout.lay_bottom_bar_notes, null);

    this.addView(noteBar, lparams);
知道出了什么问题吗?
谢谢!

我有同样的问题。但您也应该向我们展示您的布局XML。