From 56ac9612bc4a3dde1ce9b97cfdee44e1ee4c0044 Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 23 Jun 2021 16:52:11 +0200 Subject: [PATCH] Fixed scrolling to found option --- app/src/main/java/eu/faircode/email/FragmentBase.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentBase.java b/app/src/main/java/eu/faircode/email/FragmentBase.java index 6e3c117917..31dbcd7fa0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentBase.java +++ b/app/src/main/java/eu/faircode/email/FragmentBase.java @@ -29,6 +29,7 @@ import android.content.IntentFilter; import android.content.IntentSender; import android.content.pm.PackageManager; import android.content.res.Configuration; +import android.graphics.Rect; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -37,6 +38,7 @@ import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.ViewParent; import android.view.inputmethod.InputMethodManager; import android.widget.ScrollView; import android.widget.TextView; @@ -129,7 +131,10 @@ public class FragmentBase extends Fragment { scroll.post(new Runnable() { @Override public void run() { - scroll.scrollTo(0, child.getTop()); + Rect rect = new Rect(); + child.getDrawingRect(rect); + scroll.offsetDescendantRectToMyCoords(child, rect); + scroll.scrollTo(0, rect.top - scroll.getPaddingTop()); } }); }