Scroll to bottom of manual setup

This commit is contained in:
M66B 2022-01-29 09:23:43 +01:00
parent a47bd8aed9
commit 115eccbde8
1 changed files with 13 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.net.ConnectivityManager;
@ -46,6 +47,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ScrollView;
import android.widget.TextView;
import androidx.annotation.NonNull;
@ -370,7 +372,17 @@ public class FragmentSetup extends FragmentBase {
@Override
public void run() {
try {
scrollTo(R.id.ibManual, 0);
Rect rect = new Rect();
cardManual.getDrawingRect(rect);
view.offsetDescendantRectToMyCoords(cardManual, rect);
int vh = view.getHeight();
int ch = rect.height();
if (vh > 0 && ch > 0) {
int y = rect.top - (vh - ch);
if (y > 0 && view instanceof ScrollView)
((ScrollView) view).scrollTo(0, y);
}
} catch (Throwable ex) {
Log.e(ex);
}