Fix layout issues in some bottom app bars and fabs.

This commit is contained in:
Alex Ning 2020-12-26 19:49:21 +08:00
parent 44c758204c
commit 196219ba01
3 changed files with 3 additions and 35 deletions

View File

@ -281,7 +281,7 @@ public class ViewPostDetailActivity extends BaseActivity implements FlairBottomS
int navBarHeight = getNavBarHeight(); int navBarHeight = getNavBarHeight();
if (navBarHeight > 0) { if (navBarHeight > 0) {
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
params.bottomMargin = navBarHeight; params.bottomMargin += navBarHeight;
fab.setLayoutParams(params); fab.setLayoutParams(params);
mRecyclerView.setPadding(0, 0, 0, navBarHeight + mRecyclerView.getPaddingBottom()); mRecyclerView.setPadding(0, 0, 0, navBarHeight + mRecyclerView.getPaddingBottom());
showToast = true; showToast = true;

View File

@ -4,16 +4,13 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.graphics.Point;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -265,20 +262,7 @@ public class ViewSubredditDetailActivity extends BaseActivity implements SortTyp
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
params.bottomMargin += navBarHeight; params.bottomMargin += navBarHeight;
fab.setLayoutParams(params); fab.setLayoutParams(params);
coordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { bottomNavigationView.setPadding(0, 0, 0, navBarHeight);
@Override
public void onGlobalLayout() {
coordinatorLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
if (size.y == coordinatorLayout.getHeight()) {
linearLayoutBottomAppBar.setPadding(0,
linearLayoutBottomAppBar.getPaddingTop(), 0, navBarHeight);
}
}
});
} }
showToast = true; showToast = true;

View File

@ -5,18 +5,15 @@ import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.ColorStateList; import android.content.res.ColorStateList;
import android.content.res.Resources; import android.content.res.Resources;
import android.graphics.Point;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.Display;
import android.view.Gravity; import android.view.Gravity;
import android.view.KeyEvent; import android.view.KeyEvent;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window; import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -304,20 +301,7 @@ public class ViewUserDetailActivity extends BaseActivity implements SortTypeSele
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams();
params.bottomMargin += navBarHeight; params.bottomMargin += navBarHeight;
fab.setLayoutParams(params); fab.setLayoutParams(params);
coordinatorLayout.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { bottomNavigationView.setPadding(0, 0, 0, navBarHeight);
@Override
public void onGlobalLayout() {
coordinatorLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this);
Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getRealSize(size);
if (size.y == coordinatorLayout.getHeight()) {
linearLayoutBottomAppBar.setPadding(0,
linearLayoutBottomAppBar.getPaddingTop(), 0, navBarHeight);
}
}
});
} }
showToast = true; showToast = true;
} }