2

2 つの Web ビューでレイアウトを作成しようとしています。私の問題は、別の webview の上に配置したいときです。それらは異なる位置に置かれます。ありがとうございます!!;)

ここに私のコードを書きます:

<?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:id="@+id/webview2"
         android:layout_width="match_parent"
         android:layout_height="50dp"
         android:autoLink="web"
         android:scrollbars="none"
         android:textColor="@android:color/black" />


<WebView
    android:id="@+id/webview1"
    android:layout_width="match_parent"
    android:layout_height="570dp"
    android:autoLink="web"
    android:scrollbars="none"
    android:textColor="@android:color/black" />

 </LinearLayout>
4

3 に答える 3

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


     <WebView
         android:id="@+id/webview2"
         android:layout_width="match_parent"
         android:layout_height="50dp"
         android:autoLink="web"
         android:scrollbars="none"
         android:textColor="@android:color/black" />


<WebView
    android:id="@+id/webview1"
    android:layout_width="match_parent"
    android:layout_height="570dp"
    android:autoLink="web"
    android:scrollbars="none"
    android:textColor="@android:color/black" />

 </FrameLayout>
于 2012-04-25T08:01:53.903 に答える
1

これは、一方が他方の上に物理的に重なるように、つまり、それを覆うようにそれらを積み重ねようとしているかどうか、または画面上に両方を積み重ねて一方が上に、もう一方はその下に、下に向かっています。

その場合は、それらを RelativeLayout に配置し、android:layout_align.... と android:layout_above|below プロパティを組み合わせて並べることをお勧めします。

次に、layout_above|below 属性を変更することでそれらを切り替えることができます。

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


 <WebView
     android:id="@+id/webview2"
     android:layout_width="match_parent"
     android:layout_height="50dp"
     android:autoLink="web"
     android:scrollbars="none"
     android:textColor="@android:color/black" />


<WebView
android:id="@+id/webview1"
android:layout_width="match_parent"
android:layout_height="570dp"
android:autoLink="web"
android:scrollbars="none"
android:textColor="@android:color/black" 
android:layout_below="@id/webview2"
android:layout_alignParentLeft="true"/>

</RelativeLayout>
于 2012-04-25T08:07:05.697 に答える
0

両方の Web ビューをフレームレイアウトに配置してみてください。それはビューを積み重ねます。

于 2012-04-25T07:58:27.447 に答える