Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android layout problem. 1px white line at right and bottom #654

Open
verisay opened this issue Jan 27, 2020 · 2 comments
Open

Android layout problem. 1px white line at right and bottom #654

verisay opened this issue Jan 27, 2020 · 2 comments

Comments

@verisay
Copy link

verisay commented Jan 27, 2020

System info

Issue occurs on: Android
Plugin version: 0.3.10+1
Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.14.4, on Mac OS X 10.15.2 19C57, locale en)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] Connected device (2 available)

• No issues found!

Steps to Reproduce

  1. create a fresh project with only WebviewScaffold
  2. enter a dark webpage url for ex. (https://www.blakeallendesign.com/)
  3. voila. There is a 1px white line at right and there is 1px white line at bottom

The layout of the webview scaffold is set in this file

/Users/edex/.pub-cache/hosted/pub.dartlang.org/flutter_webview_plugin-0.3.10+1/android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java

I think its a pixel density calculation' problem

FrameLayout.LayoutParams params;
        if (rc != null) {
            params = new FrameLayout.LayoutParams(
              dp2px(activity, rc.get("width").intValue() +1),
              dp2px(activity, rc.get("height").intValue() +1)
            );

            params.setMargins(
              dp2px(activity, rc.get("left").intValue()),
              dp2px(activity, rc.get("top").intValue()),
              0,0
            );

0.5f is the default offset value I've tested with these values

0.0f lines become thicker 2x
1.0f lines appears at left and top this time
0.9f same as 0.5
0.99f same as 0.5
-0.5 same as 0.0f

private int dp2px(Context context, float dp) {
        final float scale = context.getResources().getDisplayMetrics().density;
        return (int) (dp * scale + 0.5f);
    }

The solution is to add +1 to width and heigh then the fractions doesnt matter

@Chathula
Copy link

Chathula commented May 3, 2020

@verisay how did u manage to fix this? I also have same issue.

@06153
Copy link

06153 commented May 8, 2020

@verisay how did u manage to fix this? I also have same issue.

this worked for me. Only that I had to use MediaQuery.of(context).size.height + 1 for height as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants