java - Web view in XML lying under main bar -


i building app has webview configured in xml (fragment_recent_news) driven file (recent news), while webview configured meet main bar in xml (see picture), webview goes further under main bar should, though not following relative layout guidelines. doing wrong?

fragment_recent_news(xml):

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.hardingsoftware.hrcfitness.recentnews">   <webview     android:layout_width="fill_parent"     android:layout_height="fill_parent"     android:id="@+id/webview"     android:layout_alignparentleft="true"     android:layout_alignparentstart="true"     android:layout_alignparentbottom="true"     android:layout_alignparentright="true"     android:layout_alignparentend="true" />   </relativelayout> 

recentnews:

package com.hardingsoftware.hrcfitness;   import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient;   /**  * simple {@link fragment} subclass.  */ public class recentnews extends fragment {      webview webview;      //final static string myblogaddr = "http://www.hrcfitness.com/recent-news/";     //string myurl;       public recentnews() {         // required empty public constructor     }          @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         // inflate layout fragment          view rootview = inflater.inflate(r.layout.fragment_recent_news, container, false);         webview mywebview = (webview) rootview.findviewbyid(r.id.webview);         mywebview.loadurl("http://hrcfitness.com");         websettings websettings = mywebview.getsettings();         websettings.setjavascriptenabled(true);         return rootview;      }       public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);     }  } 

enter image description here

styles.xml

<!-- base application theme. --> <style name="apptheme" parent="theme.appcompat.light.darkactionbar">     <!-- customize theme here. -->     <item name="colorprimary">@color/colorprimary</item>     <item name="colorprimarydark">@color/colorprimarydark</item>     <item name="coloraccent">@color/coloraccent</item> </style> <style name="apptheme.noactionbar">     <item name="windowactionbar">true</item>     <item name="windownotitle">true</item> </style> <style name="apptheme.appbaroverlay" parent="themeoverlay.appcompat.dark.actionbar" /> <style name="apptheme.popupoverlay" parent="themeoverlay.appcompat.light" /> 

activity_main.xml

<?xml version="1.0" encoding="utf-8"?> 

<include layout="@layout/app_bar_main" android:layout_width="match_parent"     android:layout_height="match_parent" />  <android.support.design.widget.navigationview android:id="@+id/nav_view"     android:layout_width="wrap_content" android:layout_height="match_parent"     android:layout_gravity="start" android:fitssystemwindows="true"     app:headerlayout="@layout/nav_header_main" app:menu="@menu/activity_main_drawer" /> 

mainactivity:

package com.hardingsoftware.hrcfitness;  import android.os.bundle; import android.support.design.widget.floatingactionbutton; import android.support.design.widget.navigationview; import android.support.design.widget.snackbar; import android.support.v4.view.gravitycompat; import android.support.v4.widget.drawerlayout; import android.support.v7.app.actionbardrawertoggle; import android.support.v7.app.appcompatactivity; import android.support.v7.widget.toolbar; import android.view.menu; import android.view.menuitem; import android.view.view;  public class mainactivity extends appcompatactivity         implements navigationview.onnavigationitemselectedlistener {      navigationview navigationview = null;     toolbar toolbar = null;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      //set fragment     homefragment fragment = new homefragment();     android.support.v4.app.fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction();     fragmenttransaction.replace(r.id.fragment_container, fragment);     fragmenttransaction.commit();      toolbar = (toolbar) findviewbyid(r.id.toolbar);     setsupportactionbar(toolbar);       drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     actionbardrawertoggle toggle = new actionbardrawertoggle(             this, drawer, toolbar, r.string.navigation_drawer_open, r.string.navigation_drawer_close);     drawer.setdrawerlistener(toggle);     toggle.syncstate();      navigationview = (navigationview) findviewbyid(r.id.nav_view);     navigationview.setnavigationitemselectedlistener(this); }  @override public void onbackpressed() {     drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     if (drawer.isdraweropen(gravitycompat.start)) {         drawer.closedrawer(gravitycompat.start);     } else {         super.onbackpressed();     } }  @override public boolean oncreateoptionsmenu(menu menu) {     // inflate menu; adds items action bar if present.     getmenuinflater().inflate(r.menu.main, menu);     return true; }  @override public boolean onoptionsitemselected(menuitem item) {     // handle action bar item clicks here. action bar     // automatically handle clicks on home/up button, long     // specify parent activity in androidmanifest.xml.     int id = item.getitemid();      //noinspection simplifiableifstatement     if (id == r.id.action_settings) {         return true;     }      return super.onoptionsitemselected(item); }  @suppresswarnings("statementwithemptybody") @override public boolean onnavigationitemselected(menuitem item) {     // handle navigation view item clicks here.     int id = item.getitemid();      if (id == r.id.nav_1) {        homefragment fragment = new homefragment();         android.support.v4.app.fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction();         fragmenttransaction.replace(r.id.fragment_container, fragment);         fragmenttransaction.commit();     } else if (id == r.id.nav_2) {     membershipcard fragment = new membershipcard();     android.support.v4.app.fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction();     fragmenttransaction.replace(r.id.fragment_container, fragment);     fragmenttransaction.commit();     } else if (id == r.id.nav_3) {         recentnews fragment = new recentnews();         android.support.v4.app.fragmenttransaction fragmenttransaction = getsupportfragmentmanager().begintransaction();         fragmenttransaction.replace(r.id.fragment_container, fragment);         fragmenttransaction.commit(); }      drawerlayout drawer = (drawerlayout) findviewbyid(r.id.drawer_layout);     drawer.closedrawer(gravitycompat.start);     return true; } } 

android manifest xml

<?xml version="1.0" encoding="utf-8"?> 

<application     android:allowbackup="true"     android:icon="@mipmap/app_icon"     android:label="@string/app_name"     android:supportsrtl="true"     android:theme="@style/apptheme" >     <activity         android:name=".mainactivity"         android:label="@string/app_name"         android:theme="@style/apptheme.noactionbar" >         <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application>  <uses-permission android:name="android.permission.internet" /> 

app_bar_main.xml

  <?xml version="1.0" encoding="utf-8"?> <android.support.design.widget.coordinatorlayout     xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"     android:layout_height="match_parent" android:fitssystemwindows="true"     tools:context=".mainactivity">      <android.support.design.widget.appbarlayout android:layout_height="wrap_content"         android:layout_width="match_parent" android:theme="@style/apptheme.appbaroverlay">          <android.support.v7.widget.toolbar android:id="@+id/toolbar"             android:layout_width="match_parent" android:layout_height="?    attr/actionbarsize"             android:background="?attr/colorprimary" app:popuptheme="@style/apptheme.popupoverlay" />      </android.support.design.widget.appbarlayout>     <relativelayout         android:id="@+id/fragment_container"         android:layout_width="match_parent"         android:layout_height="match_parent"></relativelayout>  </android.support.design.widget.coordinatorlayout> 

please remove

android:theme="@style/apptheme.noactionbar" manifest file. should work.

edit:

i did not know using coordinatorlayout

add android:theme="@style/apptheme.noactionbar" , put

app:layout_behavior="@string/appbar_scrolling_view_behavior" following component below.

<relativelayout         android:id="@+id/fragment_container"          app:layout_behavior="@string/appbar_scrolling_view_behavior" 

component.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -