正在加载数据时,默认情况下可见的ProgressBar
将显示在活动的中间。在后台,如果ViewPager
的内容小于我的目标大小,则将调整其大小以匹配它。
Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(new Runnable() {
@Override
public void run() {
ViewGroup.LayoutParams params = view.getLayoutParams();
params.height = heightToAdd;
view.setLayoutParams(params);
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
int heightWas = oldBottom - oldTop;
if (v.getHeight() != heightWas) {
}
}
});
}
}, 500);
问题在于,只要更改视图的高度,ProgressBar
就会冻结。