在Android的WebView中保持下一个按钮 [英] Keeping a Button under WebView in Android

查看:86
本文介绍了在Android的WebView中保持下一个按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有麻烦显示(也是最重要的是 - 保存)下的WebView一个按钮,所以它会呆在那里,而不是使用loadURL的呼叫后的WebView吃掉了()。我可以看到在正确的地方按钮时模拟器启动,但在页面加载时,web视图始终占据整个屏幕。 Android SDK中为1.5。

下面是布局:

 < RelativeLayout的机器人:ID =@ + ID / RelativeLayout01
                机器人:layout_width =FILL_PARENT
                机器人:layout_height =FILL_PARENT
                的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>  <按钮的android:文本=确定
          机器人:ID =@ + ID / btnOk
          机器人:layout_width =120像素
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_gravity =CENTER_HORIZONTAL
          机器人:layout_alignParentBottom =真
          机器人:layout_centerHorizo​​ntal =真/>
    <的WebView机器人:ID =@ + ID / webview1
           机器人:layout_above =@ + ID / btnOk
           机器人:layout_width =FILL_PARENT
           机器人:layout_height =FILL_PARENT
           />
< / RelativeLayout的>


解决方案

设置的android:layout_weight =1您的WebView元素和它括在一个的LinearLayout:

 <的LinearLayout机器人:ID =@ + ID / LinearLayout01
    机器人:layout_width =FILL_PARENT
    机器人:layout_height =FILL_PARENT
    的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>  <的WebView机器人:ID =@ + ID / webview1
         机器人:layout_above =@ + ID / btnOk
         机器人:layout_width =FILL_PARENT
         机器人:layout_height =FILL_PARENT
         机器人:layout_weight =1/>
  <按钮的android:文本=确定
          机器人:ID =@ + ID / btnOk
          机器人:layout_width =120像素
          机器人:layout_height =WRAP_CONTENT
          机器人:layout_gravity =CENTER_HORIZONTAL
          机器人:layout_centerHorizo​​ntal =真/>
< / LinearLayout中>

I have trouble displaying(and most importantly - keeping) a Button under WebView, so it will stay there and not get eaten up by WebView after a call of loadUrl(). I can see the Button in the right place when the emulator starts up, but when the page loads, the WebView always occupies the whole screen. Android SDK is 1.5.

Here is the layout:

<RelativeLayout android:id="@+id/RelativeLayout01" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent"
                xmlns:android="http://schemas.android.com/apk/res/android">

  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_alignParentBottom="true"
          android:layout_centerHorizontal="true"/>
    <WebView android:id="@+id/webview1"
           android:layout_above="@+id/btnOk"
           android:layout_width="fill_parent"
           android:layout_height="fill_parent"
           /> 
</RelativeLayout>

解决方案

Set android:layout_weight="1" on your WebView element and enclose it in a LinearLayout:

<LinearLayout android:id="@+id/LinearLayout01" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"
    xmlns:android="http://schemas.android.com/apk/res/android">

  <WebView android:id="@+id/webview1"
         android:layout_above="@+id/btnOk"
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:layout_weight="1"/> 
  <Button android:text="Ok" 
          android:id="@+id/btnOk" 
          android:layout_width="120px" 
          android:layout_height="wrap_content"
          android:layout_gravity="center_horizontal"
          android:layout_centerHorizontal="true"/>
</LinearLayout>

这篇关于在Android的WebView中保持下一个按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆