androidandroid-tablelayoutrow-height

Two tableviews with same row heights (Android)


I have a view with two tables. One is used as titles column (static) and other for data. (Linear layout, horizontal).

I need somehow to read the heights of each row in data table, and make the rows at titles table be at the same height...

enter image description here


Solution

  • Use this below code to read your View Height :

     view.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                                    @Override
                                    public void onGlobalLayout() {
                                    //TO remove listener
                                        view.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                                    int height = view.getHeight();
                                    int width = view.getWidth();
                                    }
                                });