我有一个包含WebView的NestedScrollView。 WebView包含一个HTML文件,其中包含锚点,这些锚点链接到相同的文件但不同的位置(想象一下“菜单”和“内容”容器。当您单击菜单项时,“内容”中对应的部分应出现在屏幕上)。
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:id="@+id/svNested"
android:layout_height="match_parent"
tools:showIn="@layout/activity_single"
android:background="@color/colorPrimary">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.NestedScrollView>
加载数据:
webView?.loadDataWithBaseURL(null, htmlContent, "text/html", "UTF-8", null)
问题在于这些锚点的效果与预期不符。