2014-05-13 41 views
0

在我的應用程序中,我需要打開包含長HTML文件的WebView。如何在WebView的末尾添加TextView

我想在WebView的末尾添加一個TextView,以便只有當用戶完成滾動WebView時,TextView纔會顯示。

我已經用這個佈局,但是,毫無疑問,試圖當我完成滾動的WebView TextView的不顯示

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<WebView 
    android:id="@+id/webView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="TextView" /> 

</LinearLayout> 
+3

你試過把它們放在scrollview中嗎? – njzk2

回答

1

你應該添加一個ScrollView其中包含您LinearLayout。在你的代碼中:

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
> 
<LinearLayout 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<WebView 
    android:id="@+id/webView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    /> 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="TextView" /> 

</LinearLayout> 

</ScrollView>