android - Default title bar displayed before my custom title bar appears -
i' developing android app , need use custom title bar using picture , 2 buttons. thing is, when launch app, during 1 or 2 seconds before custom title bar appears, there ugly default 1 "my application" displayed. minimum targeted api 15.
all answers found on stack overflow didn't work, or succeed make disappear doing same custom title bar.
here how call activity:
supportrequestwindowfeature(window.feature_custom_title); super.oncreate(savedinstancestate); getwindow().setfeatureint(window.feature_custom_title,r.layout.topbarclassic);
since first view fragment dont call setcontentview
and custom styles.xml:
<resources> <style name="theme" parent="theme.appcompat.light.noactionbar"> <item name="android:windowtitlesize">50dp</item> <item name="android:windownotitle">false</item> </style> </resources>
once again custom title bar works properly. need rid of default 1 displayed when app starts. lot!
if use style activity load without action bar
<style name="theme" parent="theme.appcompat.light.noactionbar"> <item name="windowactionbar">false</item> <item name="windownotitle">true</item> </style>
then should using toolbar set action bar. example :
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="wrap_content" android:minheight="?attr/actionbarsize" /> </relativelayout>
then in activity can set action bar this:
@override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(...); toolbar toolbar = (toolbar) findviewbyid(r.id.toolbar); setsupportactionbar(toolbar); getsupportactionbar().setdisplayhomeasupenabled(true); }
dont forget set them in androidmanifest.xml
<activity android:name=".path.myactivity" android:theme="@style/theme"/>
Comments
Post a Comment