From c19a3b37771d692f9804b944d4feba229c6fe09c Mon Sep 17 00:00:00 2001 From: Peter Osterlund Date: Mon, 13 Jan 2020 21:42:08 +0100 Subject: [PATCH] Improve scrolling behavior of the MoveList area Move the margin between the move list and the button row to the button row container, so that the margin does not interfere with the calculation in MoveListView.onMeasure(). Adjusted the MoveListView content size so that the last row can be scrolled to a position where the previous line is completely hidden. --- .../main/java/org/petero/droidfish/view/MoveListView.java | 5 +++-- DroidFishApp/src/main/res/layout/main.xml | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DroidFishApp/src/main/java/org/petero/droidfish/view/MoveListView.java b/DroidFishApp/src/main/java/org/petero/droidfish/view/MoveListView.java index 28f5a14..ad46609 100644 --- a/DroidFishApp/src/main/java/org/petero/droidfish/view/MoveListView.java +++ b/DroidFishApp/src/main/java/org/petero/droidfish/view/MoveListView.java @@ -139,12 +139,13 @@ public class MoveListView extends View { int height = 0; if (layout != null) { - height = layout.getLineCount() * getLineHeight(); + int nLines = layout.getLineCount(); + height = nLines * getLineHeight(); ViewParent p = getParent(); if (p != null) p = p.getParent(); if (p instanceof MyRelativeLayout) - height += -getLineHeight() + ((MyRelativeLayout)p).getNewHeight(); + height = getLineStartY(nLines - 1) + ((MyRelativeLayout)p).getNewHeight(); } switch (MeasureSpec.getMode(heightMeasureSpec)) { case MeasureSpec.UNSPECIFIED: diff --git a/DroidFishApp/src/main/res/layout/main.xml b/DroidFishApp/src/main/res/layout/main.xml index 1931d73..3c22d13 100644 --- a/DroidFishApp/src/main/res/layout/main.xml +++ b/DroidFishApp/src/main/res/layout/main.xml @@ -42,7 +42,8 @@ android:id="@+id/buttons" android:orientation="horizontal" android:layout_width="wrap_content" - android:layout_height="wrap_content"> + android:layout_height="wrap_content" + android:layout_marginBottom="4dp"> + android:layout_height="fill_parent">