Web View takes up the whole screen

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Web View takes up the whole screen

Postby arin » Thu Jul 09, 2009 10:25 am

Hi I have a screen that is divided into 3 absolute layouts, now I want the 2nd layout to display a webpage while the 1st and the 3rd displays something else. I cannot achieve this. Whenever I am running the program and the webview inside the 2nd layout gets activated it takes up the whole screen. Is there any way out?

heres how I constructed my main layout :

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <LinearLayout
  4.  
  5. android:id="@+id/widget28"
  6.  
  7. android:layout_width="fill_parent"
  8.  
  9. android:layout_height="fill_parent"
  10.  
  11. android:orientation="vertical"
  12.  
  13. xmlns:android="http://schemas.android.com/apk/res/android"
  14.  
  15. >
  16.  
  17. <AbsoluteLayout
  18.  
  19. android:id="@+id/widget29"
  20.  
  21. android:layout_width="320px"
  22.  
  23. android:layout_height="50px"
  24.  
  25. >
  26.  
  27. <TextView
  28.  
  29. android:id="@+id/widget31"
  30.  
  31. android:layout_width="wrap_content"
  32.  
  33. android:layout_height="wrap_content"
  34.  
  35. android:layout_marginBottom="5px"
  36.  
  37. android:text=""
  38.  
  39. android:textSize="18sp"
  40.  
  41. android:typeface="monospace"
  42.  
  43. android:layout_x="87px"
  44.  
  45. android:layout_y="10px"
  46.  
  47. >
  48.  
  49. </TextView>
  50.  
  51. </AbsoluteLayout>
  52.  
  53. <AbsoluteLayout
  54.  
  55. android:id="@+id/widget33"
  56.  
  57. android:layout_width="320px"
  58.  
  59. android:layout_height="330px">
  60.  
  61. <WebView android:id="@+id/webview" android:layout_width="320px"
  62.  
  63.                 android:layout_height="330px" />
  64.  
  65. </AbsoluteLayout>
  66.  
  67. <AbsoluteLayout
  68.  
  69. android:id="@+id/widget34"
  70.  
  71. android:layout_width="320px"
  72.  
  73. android:layout_height="50px"
  74.  
  75. >
  76.  
  77. <ImageView
  78.  
  79. android:id="@+id/widget35"
  80.  
  81. android:layout_width="48px"
  82.  
  83. android:layout_height="48px"
  84.  
  85. android:layout_x="14px"
  86.  
  87. android:layout_y="1px"
  88.  
  89. android:background="@drawable/idisk">
  90.  
  91. </ImageView>
  92.  
  93. <ImageView
  94.  
  95. android:id="@+id/widget55"
  96.  
  97. android:layout_width="48px"
  98.  
  99. android:layout_height="48px"
  100.  
  101. android:layout_x="82px"
  102.  
  103. android:layout_y="1px"
  104.  
  105. android:background="@drawable/idiskgreen">
  106.  
  107. </ImageView>
  108.  
  109. <ImageView
  110.  
  111. android:id="@+id/widget56"
  112.  
  113. android:layout_width="48px"
  114.  
  115. android:layout_height="48px"
  116.  
  117. android:layout_x="149px"
  118.  
  119. android:layout_y="1px"
  120.  
  121. android:background="@drawable/movie">
  122.  
  123. </ImageView>
  124.  
  125. <ImageView
  126.  
  127. android:id="@+id/widget57"
  128.  
  129. android:layout_width="48px"
  130.  
  131. android:layout_height="48px"
  132.  
  133. android:layout_x="216px"
  134.  
  135. android:layout_y="1px"
  136.  
  137. android:background="@drawable/photo">
  138.  
  139. </ImageView>
  140.  
  141. </AbsoluteLayout>
  142.  
  143. </LinearLayout>
Parsed in 0.008 seconds, using GeSHi 1.0.8.4


The java looks like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class MainView extends Activity {
  2.  
  3.        
  4.  
  5.         WebView webview;
  6.  
  7.     /** Called when the activity is first created. */
  8.  
  9.     @Override
  10.  
  11.     public void onCreate(Bundle savedInstanceState) {
  12.  
  13.         super.onCreate(savedInstanceState);
  14.  
  15.         setContentView(R.layout.main);
  16.  
  17.        
  18.  
  19.         try{
  20.  
  21.         webview = (WebView) findViewById(R.id.webview);
  22.  
  23.         webview.getSettings().setJavaScriptEnabled(true);
  24.  
  25.         webview.loadUrl("http://m.twitter.com");
  26.  
  27.         } catch(Exception e){
  28.  
  29.                 e.printStackTrace();
  30.  
  31.         }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


the web view takes up the whole screen although I want it to display in the certain area in the screen. Is there any other way to do it? Please help
arin
Junior Developer
Junior Developer
 
Posts: 13
Joined: Thu Jul 09, 2009 10:17 am

Top

Postby arin » Sun Jul 12, 2009 6:55 pm

wow, there are 64 views with not a single reply.. and u call them geeks?

Anyway I found a solution here:
http://android-developers.blogspot.com/2008/09/using-webviews.html
arin
Junior Developer
Junior Developer
 
Posts: 13
Joined: Thu Jul 09, 2009 10:17 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 9 guests