Android Question Why doesn't an inner Panel redraw itself when its dimensions are changed?

Tom_707

Member
Licensed User
When the dimensions of the inner Panel of a ScrollView or HorizontalScrollView get changed, the following code needs to be used so that the Panel redraws itself:
B4X:
Dim jo As JavaObject = HSV.Panel
jo.RunMethod("requestLayout", Null)


But the original Java code for a PanelWrapper, which extends a ViewWrapper, already uses the requestLayout method:
Java:
    public void setWidth(@Pixel int width) {
        ViewGroup.LayoutParams lp = getLayoutParams();
        lp.width = width;
        requestLayout();
    }
    public void setHeight(@Pixel int height) {
        ViewGroup.LayoutParams lp = getLayoutParams();
        lp.height = height;
        requestLayout();
    }


Why does the requestLayout method in the original code work for all Views, but not for an inner Panel?

(I am aware of xCustomListView, but I would like to know why this code is not working properly).
 

drgottjr

Expert
Licensed User
Longtime User
there is a connection between invalidate() and requestLayout(). using both may seem counterintuitive, but give it a try (invalidate comes first).
 
Upvote 0
Top