安卓半屏网页浏览器

4

我只是想这样做,但不知道怎么做。这将采用垂直线性布局。我已经搜索了3个小时,但还没有找到有用的信息。


请查看这个问题:https://dev59.com/am855IYBdhLWcg3wfUVM - jorgenfb
@Tomi S:嗨,我遇到了一个问题...如果我在Web视图(高度=200dp)中打开google.com或者说yahoo.com,它会显示前200dp的空白Web视图,然后全屏打开google/yahoo页面...我只是尝试使用www.ya.com,它对我有用...这里有什么帮助吗? - CoDe
如果我点击任何链接,它会在一个新的全屏页面中打开,而不是在同一个200dp高度的Webview中打开...你有什么想法吗? - CoDe
3个回答

7

将您的子视图的权重设置为相等的值将使它们均匀分割:

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

    <WebView 
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />

    <Space
        android:layout_width="fill_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />
</LinearLayout>

谢谢您提供正确的例子,但是nithinreddy回答了第一个问题,所以我必须检查他的答案。 - Tomi S

3

我之前用了两个webview来实现这个功能。我使用了android:layout_weight属性,将两个webview的值都设置为1,这样就填满了整个屏幕。

如果你只想要一个webview,可以使用另一个线性布局来放置其他项目,并将android:layout_weight属性同时设置为1,这样就可以实现同样的效果。


0
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_height="wrap_content" 
      android:layout_width="fill_parent"               
      android:weightSum="1">

网页浏览器按钮

 button = (Button) findViewById(R.id.btn_webbrowser);
 button.setOnClickListener(new OnClickListener()
 {
    public void onClick(View arg0){
        Intent i = new
        Intent(android.content.Intent.ACTION_VIEW,
    Uri.parse(“http://www.amazon.com”));
 startActivity(i);
  }
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接