gpt4 book ai didi

Android webview 空白 - Android 28 SDK

转载 作者:行者123 更新时间:2023-12-02 12:44:38 24 4
gpt4 key购买 nike

最近,我将应用中的 compileSdkVersiontargetSdkVersion27 更新为 28。我在一个屏幕中使用 Webview 只是为了显示对齐的文本。

这是代码

 WebView webView = findViewById(R.id.webView);
String text = "Lorem ipsum dollar sit amet. Lorem ipsum dollar sit amet. Lorem ipsum dollar sit amet. Lorem ipsum dollar sit amet. Lorem ipsum dollar sit amet.";
String contentStr = String.valueOf(Html
.fromHtml("<![CDATA[<body style=\"text-align:justify;color:#80000000; \"><i><small>"
+ text
+ "</small></i></body>]]>"));
webView.loadDataWithBaseURL(null, contentStr, "text/html", "utf-8", null);

SDK版本为27时的输出 Output When SDK is 27

当我将 SDK 更新到 28 时,它什么也没有显示。SDK为28时的输出 Output When SDK is 28

我尝试过 webView.loadData(contentStr, "text/html", "utf-8"); 但没有结果。请帮忙。

谢谢。

最佳答案

在 AS 中运行示例代码,一切似乎都正常。

enter image description here

Gradle :

 android {
compileSdkVersion 28
defaultConfig {
applicationId "stackoverflow.tomerpacific.com.so"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}}dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'}

关于Android webview 空白 - Android 28 SDK,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53541419/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com