From c8c63057573f1a268edd31d8bb3511cd9773811e Mon Sep 17 00:00:00 2001 From: Javi Rueda Date: Tue, 22 Dec 2020 02:26:37 +0100 Subject: [PATCH] Avoid showing vertical scroll bar on stage error listview --- .../java/io/lbry/browser/MainActivity.java | 18 ++++++++++++++++++ app/src/main/res/layout/app_bar_main.xml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index 39ec4a90..11d93373 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -40,6 +40,7 @@ import android.view.KeyEvent; import android.view.MenuItem; import android.view.View; import android.view.Menu; +import android.view.ViewGroup; import android.view.WindowManager; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodManager; @@ -2750,6 +2751,23 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener StartupStageAdapter adapter = new StartupStageAdapter(this, startupStages); listView.setAdapter(adapter); + // Add 1 pixel to listview height + int listHeight = Math.round(getResources().getDisplayMetrics().density); + + for (int i = 0; i < startupStages.size(); i++) { + View item = adapter.getView(i, null, listView); + item.measure(0, 0); + listHeight += item.getMeasuredHeight(); + } + + // Properly set listview height by adding all seven items and the divider heights + // and the additional 1 pixel so no vertical scroll bar is shown + ViewGroup.LayoutParams params = listView.getLayoutParams(); + params.height = listHeight + (listView.getCount() + 1) * listView.getDividerHeight(); + listView.setLayoutParams(params); + listView.invalidate(); + listView.requestLayout(); + findViewById(R.id.splash_view_loading_container).setVisibility(View.GONE); findViewById(R.id.splash_view_error_container).setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/layout/app_bar_main.xml b/app/src/main/res/layout/app_bar_main.xml index a27be78f..2122929b 100644 --- a/app/src/main/res/layout/app_bar_main.xml +++ b/app/src/main/res/layout/app_bar_main.xml @@ -159,7 +159,7 @@