1

The title of my SplashActivity is quite long, so appears truncated beneath the launch icon on the device's home screen.

I want a shorter title shown beneath the launch icon, but a longer title shown in the Activity's action bar.

So, to try and achieve this I have specified a shorter title in the manifest...

<activity
        android:name=".SplashActivity"
        android:label="@string/app_name_short"
        android:launchMode="singleTop" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

...and I'm using...

setTitle(getString(R.string.app_name));

...in the onCreate() method of SplashActivity so that the full title appears in the action bar.

It works, but only after about a 1 second delay. (So when SplashActivity is displayed, it shows the short title for 1 second before changing to the longer title.)

Is there any way I can fix this or any known workaround?

I've also tried creating a PreSplashActivity (with a short title) as the launch activity, including code to immediately launch SplashActivity (with a long title), but PreSplashActivity is still displayed for 1 second (even though it doesn't call setContentView(), so I'm a bit stumped.

Any ideas?

ban-geoengineering
  • 18,324
  • 27
  • 171
  • 253
  • 1
    The UI will not be updated until `onCreate()` (strictly, even later than that) is complete. – Simon Jan 23 '15 at 11:51
  • Well, can't you set the *android:label* attribute of the tag? That is what is displayed under the launcher icon, at least in the Android ADT days. Dunno how much things have changed with Android Studio! – Ed_Fernando Jan 23 '15 at 11:58
  • a workaround? it's not that cool, it is very cool; ok do this _also delay your overall ui for a second_ .. user might feel a lag, but a second is not that noticeable to end user – Elltz Jan 23 '15 at 12:01
  • @Ed_Fernando , I had already tried changing the `android:label` in `` tag - makes no difference. – ban-geoengineering Jan 23 '15 at 12:07
  • @Elltz, can you provide an example of how to achieve this, taking into account Simon's comment. – ban-geoengineering Jan 23 '15 at 12:08
  • You could try running it in a Thread and let it *sleep* for the said duration, like what Elltz suggested. Though I have no clue about stalling onCreate. – Ed_Fernando Jan 23 '15 at 12:09
  • heloo, Sir please did you google? forget about delaying UI, [your exact answer](http://stackoverflow.com/questions/3488664/android-launcher-label-vs-activity-title) , if the side not concerns you then fall back to delaying – Elltz Jan 23 '15 at 12:29
  • Certainly did, but I didn't come across that one. It seems to work though - many thanks. – ban-geoengineering Jan 23 '15 at 12:35
  • @Elltz, do you want to make that into an answer so I can get this ticked off. – ban-geoengineering Jan 23 '15 at 15:21
  • okay Sir, _i already thought about that_ (just for smiles) – Elltz Jan 23 '15 at 22:50
  • sir, idk but did you forget to tick it off? just saying – Elltz Feb 03 '15 at 22:44

2 Answers2

2

In this post answered by mark Renouf made it know that intent-filters can have a label attribute If it's absent the label is inherited from the parent component

Community
  • 1
  • 1
Elltz
  • 10,730
  • 4
  • 31
  • 59
1

Have you looked at the new docs for API21, specifically Toolbar? http://developer.android.com/reference/android/widget/Toolbar.html

With the new Toolbar you include it in your layout file like any other view. A nice side effect of this is that the initial screen is blank and the action bar appears in sync with the rest of your content. This gives you the option to set the title and make any customizations necessary before it becomes visible.

Here's details about using AppCompat to support older versions, it includes a section on using Toolbar in your layout and setting it as the action bar: http://android-developers.blogspot.ie/2014/10/appcompat-v21-material-design-for-pre.html

darnmason
  • 2,672
  • 1
  • 17
  • 23
  • This looks good, but Elltz has already helped solve my issue with his comment / link, above. – ban-geoengineering Jan 23 '15 at 13:46
  • 1
    That's a good solution, I didn't know intent-filter could have its own label. It's always good to keep up to date with the latest Android guidelines though, Toolbar is worth looking into anyway. – darnmason Jan 23 '15 at 13:49