2014-01-21 33 views
1

我有大型muptipage webview(用戶協議)下的設置按鈕的問題。現在我可以在滾動webview的同時隨時看到按鈕。如何在Android上的非常大的WebView下設置按鈕?

當我將android:layout_below="@+id/rl_relativeLayout添加到佈局中的按鈕時,我只能看到WebView的內容。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<RelativeLayout 
    android:id="@+id/rl_relativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_margin="10dip" > 
<WebView 
    android:id="@+id/web_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:visibility="gone" 
    /> 

</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/rl_relativeLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_gravity="center_horizontal" 
    android:layout_margin="10dip" > 
<Button 
    android:id="@+id/agreement_acceptance" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="3dp" 
    android:text="OK" /> 
</RelativeLayout> 

回答

1

使用ScrollView

<ScrollView android:layout_height="fill_parent" 
     android:layout_width="fill_parent"> 

    <LinearLayout android:layout_height="wrap_content" 
      android:layout_width="fill_parent" 
      android:orientation="vertical"> 

     <WebView android:layout_height="wrap_content" 
       android:layout_width="fill_parent"/> 

     <Button android:layout_height="wrap_content" 
       android:layout_width="fill_parent"/> 

    </LinearLayout> 

</ScrollView> 
+0

它的作品,非常感謝你!對不起,我的聲譽很低,我不能投票答覆你的答案。 –

0

只需添加web視圖按鈕上方的按鈕對準底部;)

在你的情況類似的東西

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

<RelativeLayout 
    android:id="@+id/rl_relativeLayout2" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_margin="10dip" 
android:layout_alignParentBottom="true" > 
<Button 
    android:id="@+id/agreement_acceptance" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="3dp" 
    android:text="OK" /> 
</RelativeLayout> 

<RelativeLayout 
    android:id="@+id/rl_relativeLayout" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_margin="10dip" 
    android:layout_above="@+id/rl_relativeLayout2" 
    > 
<WebView 
    android:id="@+id/web_view" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:visibility="gone" 
    /> 

</RelativeLayout> 
+0

剛剛嘗試過這個變體,但沒有奏效。我可以向下滾動webview,但無法看到按鈕。 –

0

只需將其替換即可。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 

    <ScrollView 
     android:id="@+id/scrollView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@+id/agreement_acceptance" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" > 

      <RelativeLayout 
       android:id="@+id/rl_relativeLayout" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_margin="10dip" > 

       <WebView 
        android:id="@+id/web_view" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:visibility="gone" /> 
      </RelativeLayout> 

     </LinearLayout> 
    </ScrollView> 

    <Button 
     android:id="@+id/agreement_acceptance" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:gravity="center" 
     android:text="OK" />