Android app fullscreen with no Title bar and no Action bar -
i trying create first android app webview. last issue trying resolve have webview in fullscreen no title bar , no action bar.
my manifest:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.domain.butlerv2"> <uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.internet"/> <uses-permission android:name="android.permission.access_network_state"/> <uses-permission android:name="android.permission.access_wifi_state"/> <application android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:supportsrtl="true" android:theme="@style/apptheme.noactionbar"> <activity android:name=".mainactivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> </application> </manifest>
my mainactivity:
import android.content.context; import android.net.connectivitymanager; import android.net.networkinfo; import android.net.uri; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.view; import android.view.windowmanager; import android.webkit.websettings; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.toast; import com.google.android.gms.appindexing.action; import com.google.android.gms.appindexing.appindex; import com.google.android.gms.common.api.googleapiclient; public class mainactivity extends appcompatactivity { string answer; private googleapiclient client; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); getwindow().setflags(windowmanager.layoutparams.flag_fullscreen, windowmanager.layoutparams.flag_fullscreen); setcontentview(r.layout.activity_main); connectivitymanager cm = (connectivitymanager) getapplicationcontext().getsystemservice(context.connectivity_service); networkinfo activenetwork = cm.getactivenetworkinfo(); if (null != activenetwork) { if (activenetwork.gettype() == connectivitymanager.type_wifi) answer = "you connected wifi network"; if (activenetwork.gettype() == connectivitymanager.type_mobile) answer = "you connected mobile network"; } else answer = "no wifi connectivity"; toast.maketext(getapplicationcontext(), answer, toast.length_long).show(); webview webview = (webview) findviewbyid(r.id._webview); websettings websettings = webview.getsettings(); webview.getsettings().setjavascriptenabled(true); webview.loadurl("http://www.domain.com/app/index.php"); webview.setwebviewclient(new mybrowser()); webview.requestfocus(view.focusables_all); client = new googleapiclient.builder(this).addapi(appindex.api).build(); } @override public void onstart() { super.onstart(); client.connect(); action viewaction = action.newaction( action.type_view, "main page", uri.parse("android-app://com.domain.butlerv2/http/host/path") ); appindex.appindexapi.start(client, viewaction); } @override public void onstop() { super.onstop(); action viewaction = action.newaction( action.type_view, "main page", shown. uri.parse("http://host/path"), uri.parse("android-app://com.domain.butlerv2/http/host/path") ); appindex.appindexapi.end(client, viewaction); client.disconnect(); } private class mybrowser extends webviewclient { @override public boolean shouldoverrideurlloading(webview view, string url) { view.loadurl(url); return true; } } }
my style
<resources> <!-- 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">false</item> <item name="windownotitle">true</item> </style> <style name="apptheme.popupoverlay" parent="themeoverlay.appcompat.light" /> <style name="generalnotitle" parent="themeoverlay.appcompat.light"> <item name="android:windownotitle">true</item> </style> <style name="theme.appcompat.light.noactionbar.fullscreen" parent="@style/theme.appcompat.light"> <item name="windownotitle">true</item> <item name="windowactionbar">false</item> <item name="android:windowfullscreen">true</item> <item name="android:windowcontentoverlay">@null</item> </style> </resources>
when run app on android phone title , action bar displayed. can see doing wrong.
i have read many posts , tech papers of different has totally confused me.
can help.
regards
hope solve issue,
change androidmanifest.xml theme from,
android:theme="@style/apptheme.noactionbar"
to
android:theme="@android:style/theme.holo.light.noactionbar.fullscreen"
Comments
Post a Comment