我用新android.support.v4.widget.NestedScrollView
和我面臨的問題。NestedScrollView和高度的WebView問題
這裏是我的佈局:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
<!-- some views inside -->
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<WebView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.NestedScrollView>
我需要加載HTML裏面的TextView,所以我提出:
content.setText(Html.fromHtml(htmlString));
而且這看起來很奇怪。我的textview放在屏幕的底部。
我滑過文本後,它開始看起來很正常。
而且我覺得TextView的不僅是這些問題的看法。 我試過使用webview,但它甚至沒有顯示內容(我認爲由於不正確的高度計算)。 所以我需要的WebView或TextView的與NestedScrollView
糾正工作。
P.S.如果我在dp
中設置文本視圖高度,那麼文本看起來是正確的,但我需要wrap_content
高度。
更新15年8月7日
最後,我需要使用WebView
。亞歷克斯Facciorusso回答部分作品,但我面臨着另一個問題。當WebView
內容具有某些特定高度時,我可以看到部分內容,但我無法向下滾動。 例子:
你可以嘗試webview顯示HTML .. ?????? – Moinkhan
@Moinkhan yeap,但webview有另一個問題:它甚至沒有出現。而且我有很輕的html,所以'TextView'顯示它是正確的。 – IlyaEremin
嘗試LinearLayout高度作爲match_parent ... – Moinkhan