【问题标题】:"Expand" a webview into an android activity将 web 视图“扩展”为 android 活动
【发布时间】:2015-03-23 11:29:50
【问题描述】:

我有一个带有一些图形元素的 android 活动,例如按钮、文本字段、进度条等... 当我调用 loadUrl() (当页面加载时)时,我还有一个我想要的不可见(“消失”)webview 出现并“扩展”在活动的所有元素上。 该活动具有线性布局。 有可能吗?怎么样?

<WebView
    android:id="@+id/webView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:visibility="gone"/>

谢谢大家

【问题讨论】:

  • 好的,我有一个正确的 ImageView。但是使用相对布局并尝试移动元素,应用程序崩溃了!使用框架布局一切正常,但我不知道如何移动元素..

标签: android layout android-activity view webview


【解决方案1】:

您需要使用RelativeLayout 或FrameLayout 而不是linearlayout。两者都提供重叠。或者你可以用它们中的任何一个来包装你的线性布局。

RelativeLayout

<RelativeLayout>
   <LinearLayout/> // your compontents, use gone to show webview
   <WebView/>      // use visible, vice-versa
</RelativeLayout>

【讨论】:

  • 调用loadUrl后是否使用了visible??
  • 现在 webview 一切正常,但我还有另一个问题。使用图形工具使用相对布局和移动元素,应用程序崩溃!但是,如果我使用不带移动元素的相对布局,则应用程序可以工作!
猜你喜欢
  • 2012-10-26
  • 1970-01-01
  • 2011-07-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-07-04
相关资源
最近更新 更多