match_parent property for children in a RelativeLayout

前端 未结 5 1142
迷失自我
迷失自我 2020-12-28 14:15

In short, is it possible to tell a child in a RelativeLayout to always match the height of that RelativeLayout regardless

5条回答
  •  星月不相逢
    2020-12-28 15:00

    Add listener to list item holder so every time when holder change height, set that height to a child. i1 is for top, and i3 is for bottom.

    parent.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
            @Override
            public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {
                child.setTop(i1);
                child.setBottom(i3);
            }
        });
    

提交回复
热议问题