I
I
Ilya Chernichkin2011-09-18 19:17:00
Android
Ilya Chernichkin, 2011-09-18 19:17:00

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

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br/>
&lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br/>
android:orientation=&quot;vertical&quot;<br/>
android:layout_width=&quot;fill_parent&quot;<br/>
android:layout_height=&quot;fill_parent&quot;<br/>
&gt;<br/>
 &lt;TabHost android:id=&quot;@+id/TabHost01&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;wrap_content&quot;&gt;<br/>
 &lt;TabWidget android:id=&quot;@android:id/tabs&quot; android:layout_width=&quot;fill_parent&quot; android:layout_height=&quot;wrap_content&quot; /&gt;<br/>
 &lt;FrameLayout android:id=&quot;@android:id/tabcontent&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:paddingTop=&quot;65px&quot;&gt;<br/>
 &lt;ListView<br/>
 android:id=&quot;@+id/rssListView&quot;<br/>
 android:layout_width=&quot;fill_parent&quot;<br/>
 android:layout_height=&quot;wrap_content&quot; <br/>
 android:padding=&quot;20dip&quot;/&gt;<br/>
 &lt;WebView <br/>
 android:id=&quot;@+id/webview&quot;<br/>
 android:layout_width=&quot;fill_parent&quot;<br/>
 android:layout_height=&quot;wrap_content&quot;/&gt; <br/>
 &lt;WebView <br/>
 android:id=&quot;@+id/webview1&quot;<br/>
 android:layout_width=&quot;fill_parent&quot;<br/>
 android:layout_height=&quot;fill_parent&quot;<br/>
 /&gt; <br/>
<br/>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
pyJIoH, 2011-09-21
@INCWADRA

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>

3. In the main activity, inherited from TabActivity, load tabs, an example for one:
  TabHost tabHost = getTabHost();
  Intent intent = new Intent().setClass(this, YourWebViewActivity.class);
  TabHost.TabSpec spec = tabHost.newTabSpec("WebView1").setIndicator("WebView1").setContent(intent);
  tabHost.addTab(spec);

I
Ilya Chernichkin, 2011-09-19
@INCWADRA

No one knows?(

A
ara89, 2011-09-20
@ara89

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 question

Ask a Question

731 491 924 answers to any question