[操作疑難] 拎recyclerview內CardView高度問題

由於code+xml有d長, 所以post左係stackoverflow
http://stackoverflow.com/questio ... ecyclerview-android
有冇師兄師姐有方法拎到每張cardview既height or 總高度

不如講下,點解你想咁樣做呢?

TOP

too long didn't read , see if it is what u want
  1. cardView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
  2.             @Override
  3.             public void onGlobalLayout() {
  4.                  cardView.getViewTreeObserver().removeOnGlobalLayoutListener(this);
  5.                  int height = cardView.getHeight();
  6.             }
  7. });
複製代碼

TOP