Child of RelativeLayout is not filling the height of the RelativeLayout

后端 未结 8 1717
终归单人心
终归单人心 2021-01-02 01:04

I have a ListView which gets populated with RelativeLayouts. The content of these RelativeLayouts can change and thus change their height respectively. On each RelativeLayou

8条回答
  •  清酒与你
    2021-01-02 01:28

    I fixed by manually set layout during onLayout for invalid view:

    @Override
    protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
        super.onLayout(changed, left, top, right, bottom);
    
        int rootMarginRight = ((MarginLayoutParams)root.getLayoutParams()).rightMargin;
        int paddingRight = root.getPaddingRight() + rootMarginRight;
    
        //invalid view
        actionsContainer.layout(
                right - actions.getWidth() - paddingRight,
                0,
                right - paddingRight,
                getHeight()
        );
    }
    

提交回复
热议问题