Fix bottom app bar is under navbar in immersive mode.

This commit is contained in:
Alex Ning 2019-12-18 21:33:03 +08:00
parent dafd0796e9
commit e3445373d9
2 changed files with 6 additions and 7 deletions

View File

@ -165,6 +165,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
FloatingActionButton fab; FloatingActionButton fab;
@BindView(R.id.bottom_navigation_main_activity) @BindView(R.id.bottom_navigation_main_activity)
BottomAppBar bottomNavigationView; BottomAppBar bottomNavigationView;
@BindView(R.id.linear_layout_bottom_app_bar_main_activity)
LinearLayout linearLayoutBottomAppBar;
@BindView(R.id.subscriptions_bottom_app_bar_main_activity) @BindView(R.id.subscriptions_bottom_app_bar_main_activity)
TextView subscriptionsBottomAppBar; TextView subscriptionsBottomAppBar;
@BindView(R.id.multi_reddit_bottom_app_bar_main_activity) @BindView(R.id.multi_reddit_bottom_app_bar_main_activity)
@ -269,10 +271,8 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int navBarResourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
if (navBarResourceId > 0) { if (navBarResourceId > 0) {
int navBarHeight = resources.getDimensionPixelSize(navBarResourceId); int navBarHeight = resources.getDimensionPixelSize(navBarResourceId);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) fab.getLayoutParams(); linearLayoutBottomAppBar.setPadding(0,
params.bottomMargin = navBarHeight; (int) (6 * resources.getDisplayMetrics().density), 0, navBarHeight);
fab.setLayoutParams(params);
nestedScrollView.setPadding(0, 0, 0, navBarHeight); nestedScrollView.setPadding(0, 0, 0, navBarHeight);
} }
} }
@ -473,6 +473,7 @@ public class MainActivity extends BaseActivity implements SortTypeSelectionCallb
@Override @Override
public void onPageSelected(int position) { public void onPageSelected(int position) {
bottomNavigationView.performShow();
fab.show(); fab.show();
if (isInLazyMode) { if (isInLazyMode) {
if (position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) { if (position == sectionsPagerAdapter.getCurrentLazyModeFragmentPosition()) {

View File

@ -61,14 +61,12 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:gravity="center"
android:visibility="gone" android:visibility="gone"
app:backgroundTint="?attr/backgroundColor" app:backgroundTint="?attr/backgroundColor"
app:layout_anchorGravity="start"
app:fabAnimationMode="scale"
app:fabAlignmentMode="center"> app:fabAlignmentMode="center">
<LinearLayout <LinearLayout
android:id="@+id/linear_layout_bottom_app_bar_main_activity"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:weightSum="3" android:weightSum="3"