Answer the question
In order to leave comments, you need to log in
Android:WebView layered on TabWidget?
In general, the problem is the following
I am writing an application for Android here, I am developing a skill so to speak
And I made tabs and put WebView into two tabs, but it is displayed incorrectly when compiling
WebView is layered on the tab
here are the
screenshots .jpg
i010.radikal.ru/1109/d1/ccf5c228465a.jpg
Here is the main.xml code
<?xml version="1.0" encoding="utf-8"?><br/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"<br/>
android:orientation="vertical"<br/>
android:layout_width="fill_parent"<br/>
android:layout_height="fill_parent"<br/>
><br/>
<TabHost android:id="@+id/TabHost01" android:layout_width="fill_parent" android:layout_height="wrap_content"><br/>
<TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /><br/>
<FrameLayout android:id="@android:id/tabcontent" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="65px"><br/>
<ListView<br/>
android:id="@+id/rssListView"<br/>
android:layout_width="fill_parent"<br/>
android:layout_height="wrap_content" <br/>
android:padding="20dip"/><br/>
<WebView <br/>
android:id="@+id/webview"<br/>
android:layout_width="fill_parent"<br/>
android:layout_height="wrap_content"/> <br/>
<WebView <br/>
android:id="@+id/webview1"<br/>
android:layout_width="fill_parent"<br/>
android:layout_height="fill_parent"<br/>
/> <br/>
<br/>
Answer the question
In order to leave comments, you need to log in
A few problems: one layout runs into another, you use regular pixels (px) for padding, then density-independent ones (dip), they will disperse on different screens. The difference is described here .
There is a good example of how to use Tab Layout - hello tabwidget . The essence is this:
1. Create three separate activities: one for the ListView and two for the WebView. Describe them in the manifest.
2. You will have this layout main.xml:
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
TabHost tabHost = getTabHost();
Intent intent = new Intent().setClass(this, YourWebViewActivity.class);
TabHost.TabSpec spec = tabHost.newTabSpec("WebView1").setIndicator("WebView1").setContent(intent);
tabHost.addTab(spec);
try the frame layout, which with id "@android:id/tabcontent" fill the parent in height and width, and remove the padding. markup constants should also be in dip, not px.
WebView, in turn, wrap in a LinearLayout, which will also have a parent fill. if you need to lower the WebView below, the LinearLayout in which it is contained can be set layout_marginTop="ndip"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question