如何让webview在所有内容上方都有默认空白?

时间:2014-11-26 11:20:57

标签: android webview

我有一些特殊要求需要webview在顶部有默认空白,如下图: enter image description here

空白应该是webview内容的一部分,以便可以滚动它。我曾想过在html中添加一个空白。但我找不到任何功能来获取当前的webview html。

那么,有没有办法在webview中的所有html内容之前创建具有特定高度的空白?

更新:我找到了解决方案:FadingActionBar

1 个答案:

答案 0 :(得分:0)

试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/ic_launcher"
    android:gravity="center" >

    <WebView
        android:id="@+id/webView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:paddingTop="100dp" /> // update ur desired height

   </RelativeLayout>