fluttercommunity / fluttercommunity/flutter_webview_plugin

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

Đang mở
#654 2 bình luận 5 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Java
Star
1.5k
Fork
938
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

## 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

```java
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

```java
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
```
```

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Hướng nghiên cứu

Bắt đầu trong android/src/main/java/com/flutter_webview_plugin/FlutterWebviewPlugin.java, tập trung vào các tham số bố cục của WebView scaffold và chuyển đổi dp2px được nêu trong báo cáo. Tái hiện với một dự án Flutter mới, WebviewScaffold và một trang web tối như ví dụ được liên kết. Được xem là hoàn tất khi Android WebView lấp đầy scaffold mà không có các đường trắng 1px ở bên phải và bên dưới.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
android, flutter, java
Lĩnh vực
mobile
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.