Skip to content

Commit

Permalink
Fix #15: Improve Auto complete drop down position when cursor on the …
Browse files Browse the repository at this point in the history
…end of the visible view
  • Loading branch information
AmrDeveloper committed Feb 27, 2022
1 parent c077612 commit 58be534
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions codeview/src/main/java/com/amrdeveloper/codeview/CodeView.java
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,6 @@ public void showDropDown() {
final int[] screenPoint = new int[2];
getLocationOnScreen(screenPoint);

final Rect displayFrame = new Rect();
getWindowVisibleDisplayFrame(displayFrame);

final Layout layout = getLayout();
final int position = getSelectionStart();
final int line = layout.getLineForOffset(position);
Expand All @@ -667,8 +664,17 @@ public void showDropDown() {
dropDownHeight = modifiedDropDownHeight;
}

final Rect displayFrame = new Rect();
getWindowVisibleDisplayFrame(displayFrame);
int displayFrameHeight = displayFrame.height();

int verticalOffset = lineButton + dropDownHeight;
if (verticalOffset > displayFrameHeight) {
verticalOffset = displayFrameHeight - autoCompleteItemHeightInDp;
}

setDropDownHeight(dropDownHeight);
setDropDownVerticalOffset(lineButton + dropDownHeight);
setDropDownVerticalOffset(verticalOffset);
setDropDownHorizontalOffset((int) layout.getPrimaryHorizontal(position));

super.showDropDown();
Expand Down

0 comments on commit 58be534

Please sign in to comment.