android - Issue with full screen apk -
i've wrote first android application, got sneaky problem :d. application simple, has 1 text box, 1 button , 1 web view. web view invisible, when button clicked visible , go url written in text box application total screen. problem when click button nil @ first, sec time works. know there focus problem, think, themed with
android:theme="@android:style/theme.notitlebar.fullscreen">
so there no title bar @ top. remember when had title bar these acts took place
1 - click on button 2 - title bar appears 3 - click on button 4 - took affect
i can when create title bar invisible, steps same top.
so need help solve problem, ideas?
activity_fullscreen.xml
<framelayout 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" android:background="#0099cc" tools:context=".fullscreenactivity"> <!-- primary full-screen view. can replaced whatever view needed nowadays content, e.g. videoview, surfaceview, textureview, etc. --> <!-- framelayout insets children based on scheme windows using android:fitssystemwindows. --> <framelayout android:layout_width="match_parent" android:layout_height="match_parent" android:fitssystemwindows="true" android:background="#ff3191ff"> <linearlayout android:id="@+id/fullscreen_content_controls" style="?metabuttonbarstyle" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:background="@color/black_overlay" android:orientation="horizontal" tools:ignore="uselessparent"> </linearlayout> </framelayout> <autocompletetextview android:id="@+id/iptxt" android:layout_width="272dp" android:layout_height="59dp" android:nextfocusup="@id/iptxt" android:nextfocusleft="@id/iptxt" android:layout_gravity="center" android:textcolor="#ff26b9ff" android:textsize="10pt" android:text="192.168.1.104" android:textalignment="center" android:textstyle="bold" android:singleline="true" android:typeface="normal" android:inputtype="text" /> <button android:layout_width="fill_parent" android:layout_height="59dp" android:id="@+id/connectbtn" android:layout_gravity="bottom" android:background="#ff3191ff" android:text="connect" android:textcolor="#ffffffff" android:textsize="12pt" android:textstyle="bold" /> <webview android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/mainwbv" android:visibility="invisible"></webview> </framelayout>
androidmanifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="ir.proapp.share" > <uses-permission android:name="android.permission.internet" /> <application android:allowbackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar.fullscreen"> <activity android:name=".fullscreenactivity" android:configchanges="orientation|keyboardhidden|screensize" android:screenorientation="portrait" android:label="@string/app_name" android:theme="@android:style/theme.notitlebar.fullscreen" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application> </manifest>
fullscreenactivity.java
package ir.proapp.share; import ir.proapp.share.util.systemuihider; import android.annotation.targetapi; import android.app.activity; import android.content.pm.activityinfo; import android.os.build; import android.os.bundle; import android.os.handler; import android.view.motionevent; import android.view.view; import android.view.window; import android.view.windowmanager; import android.webkit.websettings; import android.webkit.webview; import android.widget.button; import android.widget.edittext; import org.apache.http.protocol.requestuseragent; /** * illustration full-screen activity shows , hides scheme ui (i.e. * status bar , navigation/system bar) user interaction. * * @see systemuihider */ public class fullscreenactivity extends activity { /** * whether or not scheme ui should auto-hidden after * {@link #auto_hide_delay_millis} milliseconds. */ private static final boolean auto_hide = true; /** * if {@link #auto_hide} set, number of milliseconds wait after * user interaction before hiding scheme ui. */ private static final int auto_hide_delay_millis = 3000; /** * if set, toggle scheme ui visibility upon interaction. otherwise, * show scheme ui visibility upon interaction. */ private static final boolean toggle_on_click = true; /** * flags pass {@link systemuihider#getinstance}. */ private static final int hider_flags = systemuihider.flag_hide_navigation; /** * instance of {@link systemuihider} activity. */ private systemuihider msystemuihider; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_fullscreen); final view controlsview = findviewbyid(r.id.fullscreen_content_controls); final view contentview = findviewbyid(r.id.fullscreen_content_controls); // set instance of systemuihider command scheme ui // activity. msystemuihider = systemuihider.getinstance(this, contentview, hider_flags); msystemuihider.setup(); msystemuihider .setonvisibilitychangelistener(new systemuihider.onvisibilitychangelistener() { // cached values. int mcontrolsheight; int mshortanimtime; @override @targetapi(build.version_codes.honeycomb_mr2) public void onvisibilitychange(boolean visible) { if (build.version.sdk_int >= build.version_codes.honeycomb_mr2) { // if viewpropertyanimator api available // (honeycomb mr2 , later), utilize animate // in-layout ui controls @ bottom of // screen. if (mcontrolsheight == 0) { mcontrolsheight = controlsview.getheight(); } if (mshortanimtime == 0) { mshortanimtime = getresources().getinteger( android.r.integer.config_shortanimtime); } controlsview.animate() .translationy(visible ? 0 : mcontrolsheight) .setduration(mshortanimtime); } else { // if viewpropertyanimator apis aren't // available, show or hide in-layout ui // controls. controlsview.setvisibility(visible ? view.visible : view.gone); } if (visible && auto_hide) { // schedule hide(). delayedhide(auto_hide_delay_millis); } } }); // set user interaction manually show or hide scheme ui. contentview.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { if (toggle_on_click) { msystemuihider.toggle(); } else { msystemuihider.show(); } } }); button connectbtn=(button)findviewbyid(r.id.connectbtn); connectbtn.setonclicklistener(new button.onclicklistener() { public void onclick(view v) { edittext iptetx=(edittext)findviewbyid(r.id.iptxt); webview maniwv=(webview)findviewbyid(r.id.mainwbv); websettings mainsettings=maniwv.getsettings(); mainsettings.setjavascriptenabled(true); mainsettings.setuseragentstring("mozilla/5.0 (x11; linux i686) applewebkit/537.31 (khtml, gecko) chrome/26.0.1410.63 safari/537.31"); maniwv.setvisibility(view.visible); maniwv.setwebviewclient(new ac1()); maniwv.loadurl("http://"+iptetx.gettext()+":9999"); } }); // upon interacting ui controls, delay scheduled hide() // operations prevent jarring behavior of controls going away // while interacting ui. /* findviewbyid(r.id.dummy_button).setontouchlistener(mdelayhidetouchlistener); */ } @override protected void onpostcreate(bundle savedinstancestate) { super.onpostcreate(savedinstancestate); // trigger initial hide() shortly after activity has been // created, briefly hint user ui controls // available. delayedhide(100); } /** * touch listener utilize in-layout ui controls delay hiding * scheme ui. prevent jarring behavior of controls going away * while interacting activity ui. */ view.ontouchlistener mdelayhidetouchlistener = new view.ontouchlistener() { @override public boolean ontouch(view view, motionevent motionevent) { if (auto_hide) { delayedhide(auto_hide_delay_millis); } homecoming false; } }; handler mhidehandler = new handler(); runnable mhiderunnable = new runnable() { @override public void run() { msystemuihider.hide(); } }; /** * schedules phone call hide() in [delay] milliseconds, canceling * scheduled calls. */ private void delayedhide(int delaymillis) { mhidehandler.removecallbacks(mhiderunnable); mhidehandler.postdelayed(mhiderunnable, delaymillis); } }
android fullscreen titlebar
No comments:
Post a Comment