Merge pull request #1097 from kekkyojin/remove_stages_scrollbar

Avoid showing vertical scroll bar on stage error listview
This commit is contained in:
Akinwale Ariwodola 2020-12-29 07:00:02 +01:00 committed by GitHub
commit 036b49a871
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View file

@ -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;
@ -2745,6 +2746,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);
}

View file

@ -159,7 +159,7 @@
<ListView
android:id="@+id/startup_stage_error_listview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="0dp"
android:layout_marginTop="12dp"
android:divider="@android:color/transparent"
android:dividerHeight="8dp"