2012-01-20 62 views
3

我只是想这样做,但我不知道如何。这将是垂直线性布局。我搜索了3个小时,还没有发现任何有用的东西。半屏Android视图

+0

退房这个问题:http://stackoverflow.com/问题/ 4315332/how-to-create-two-views-in-android-that-use-50-height-each-unless-one-is-small – jorgenfb

+0

@Tomi S:你好我正面临着像...... if我打开google.com或在网络视图(高度= 200dp)中说yahoo.com,它显示第一个200dp空白的网页视图,然后打开谷歌/雅虎页面全屏...我只是尝试与www.ya.com,它为我工作...在这里的任何帮助? – CoDe

+0

在这里相同...如果我点击任何链接,然后它打开一个新的全屏页面,而不是打开在相同的200dp高度webview ....任何想法在这? – CoDe

回答

2

我之前做过2个网页浏览。我通过将android:layout_weight设置为1来实现这两种视图,并且它填满了屏幕。

如果您只想要1个网页视图,请为其余项目使用另一个线性布局,并将android:layout_weight =“1”设置为webview和线性布局。

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"> 

Web浏览器按钮

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); 
    } 
}); 
5

设置等于对方你的孩子浏览的权重应该平分他们:

<?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> 
+0

谢谢你正确的例子,但nithinreddy回答了第一个,所以我必须检查他的。 –