无法测量我的底部导航栏的高度
Unable to measure the height of my Bottom Navigation Bar
我正在尝试获取底部导航栏的高度,以便我可以为导航栏上方显示的内容设置底部边距。我的问题是它总是 returns 0。这是代码:
navigation.post(new Runnable() {
@Override
public void run() {
navHeight = navigation.getMeasuredHeight();
}
});
FrameLayout frame = findViewById(R.id.frame_container);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) frame.getLayoutParams();
params.setMargins(0, 0, 0, navHeight);
frame.setLayoutParams(params);
我也试过用ViewTreeObserver
,但也没用。
我只需要将所有内容移动到 运行() 方法中
我正在尝试获取底部导航栏的高度,以便我可以为导航栏上方显示的内容设置底部边距。我的问题是它总是 returns 0。这是代码:
navigation.post(new Runnable() {
@Override
public void run() {
navHeight = navigation.getMeasuredHeight();
}
});
FrameLayout frame = findViewById(R.id.frame_container);
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) frame.getLayoutParams();
params.setMargins(0, 0, 0, navHeight);
frame.setLayoutParams(params);
我也试过用ViewTreeObserver
,但也没用。
我只需要将所有内容移动到 运行() 方法中