Reputation: 53
I'm trying to do a layout with two webviews. My problems is when I want putting one above another webview. They are put in different positions. Thank's you!! ;)
I write here my code:
<?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>
Upvotes: 2
Views: 2276
Reputation: 229
I guess this depends on whether you are trying to stack them, so that one is physically over the top of the other, i.e. covering it up, or whether you're asking to be able to stack them both on the screen so that one is at the top, and the other is below it, towards the bottom.
if that's the case, i'd suggest you place them in a RelativeLayout, and use a combination of android:layout_align.... and android:layout_above|below properties to get them lined up.
you can then switch them around by changing the layout_above|below attributes e.g.
<?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>
Upvotes: 1
Reputation: 34765
<?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>
Upvotes: 1
Reputation: 31779
Try putting both the webviews in a framelayout. That will stack the views.
Upvotes: 0