[android] Scroll down when nav drawer chevron is pressed

This commit is contained in:
Torsten Grote
2020-01-29 11:25:33 -03:00
parent aeb148c600
commit 0192b64dd3
2 changed files with 6 additions and 1 deletions

View File

@@ -47,6 +47,7 @@ import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.ViewModelProvider;
import androidx.lifecycle.ViewModelProviders;
import static android.view.View.FOCUS_DOWN;
import static android.view.View.GONE;
import static android.view.View.INVISIBLE;
import static android.view.View.VISIBLE;
@@ -114,12 +115,12 @@ public class NavDrawerActivity extends BriarActivity implements
});
drawerScrollView = findViewById(R.id.drawerScrollView);
View chevronView = drawerScrollView.findViewById(R.id.chevronView);
drawerScrollView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
// hide/show chevron depending on whether we can scroll
View chevronView = findViewById(R.id.chevronView);
if (drawerScrollView.canScrollVertically(1)) {
chevronView.setVisibility(VISIBLE);
} else {
@@ -130,6 +131,9 @@ public class NavDrawerActivity extends BriarActivity implements
}
});
new PluginViewController(drawerScrollView, this, viewModel);
chevronView.setOnClickListener(v ->
drawerScrollView.fullScroll(FOCUS_DOWN)
);
Toolbar toolbar = findViewById(R.id.toolbar);
drawerLayout = findViewById(R.id.drawer_layout);

View File

@@ -13,6 +13,7 @@
android:layout_height="24dp"
android:layout_marginBottom="8dp"
android:background="@color/divider"
android:foreground="?attr/selectableItemBackground"
android:src="@drawable/chevron_down_white"
app:layout_constraintBottom_toTopOf="@+id/longRangeLabel"
app:layout_constraintEnd_toEndOf="parent"