How to prevent Action bar from flickering when removing logo an setting title programatically
Below is the code I have in my MainActivity.java. This changes the action bar. But it first displays the actual action bar with logo and title I have given in Android Manifest.xml. Then the action bar flickers and changes to new title and no Logo.How to remove flickering and make Action bar load at once ?
ActionBar actionBar = getActionBar();
actionBar.setLogo(null);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle("Welcome Dear User");
actionBar.setDisplayUseLogoEnabled(false);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
I tried with style.xml route also
Android Manifest.xml:
<application
android:allowBackup="true"
android:icon="@mipmap/geniusicon"
android:label="@string/app_name"
android:supportsRtl="true"
android:hardwareAccelerated="false"
android:largeHeap="true"
android:theme="@android:style/Theme.Holo.Light">
<activity android:name=".MainActivity"
android:theme="@style/AppTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
Style.xml:
<style name="AppTheme" parent="@android:style/Theme.Holo.Light">
<!-- Customize your theme here. -->
<item name="android:actionBarStyle">@style/MyActionBar</item>
</style>
<style name="MyActionBar" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:background">#20a780</item>
<item name="android:titleTextStyle">@style/Theme.MyAppTheme.ActionBar.TitleTextStyle</item>
</style>
<style name="Theme.MyAppTheme.ActionBar.TitleTextStyle" parent="@android:style/Theme.Holo.Light.DarkActionBar">
<item name="android:textColor">#ff0000</item>
</style>