Getting More Elbow Room

While the T-Mobile G1’s 320×480 screen is a luxury to those who developed apps for less-spacious screens, it always seems like you could use just a bit more room. Here are two tricks for clearing off some Android-supplied UI elements, so your activities can take up more space.

First up is the activity title bar. Much like the title bar in any Windows, OS X, or (most window managers in) Linux, it shows you the name of the application you are using. Sometimes, though, that is sufficiently obvious that you would rather reclaim the space from the bar. To do that, call requestWindowFeature(Window.FEATURE_NO_TITLE); from your activity’s onCreate() callback, before you set your content view.

For example, here is a snippet from the source code to Android’s calculator app:

[sourcecode language=”java”]
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
[/sourcecode]

This is also useful as a trick to do a fancier title bar than the stock Android one — just remove theirs and supply your own, completely under your control.

To gain even more room, you can go “full screen”. This eliminates the status bar at the top of the phone display, where the signal strength, battery meter, and whatnot reside. Removing this is dangerous, in that your users might get irritated if they have no way to know how much battery life remains, for example. But, in select situations, it may be worthwhile.

To go “full screen”, use the following, before you set your content view:

[sourcecode language=”java”]
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
[/sourcecode]

About author

AndroidGuys
AndroidGuys 4639 posts

Founded on November 5, 2007, we've enjoyed bringing you the latest in Android news and rumors. Updated daily, we strive to deliver reviews, opinions, and updates on all things related to Android.

You might also like

News and Rumors

G2 Gets Closer to Release, Pops Up in FCC Filing

We told you about the G2 possibly launching on September 29th, and we’ve found something that seems to support our theory. A phone that may well be the T-Mobile G2

News and Rumors

Bsquare Porting Flash to Dell Netbooks Running Android [UPDATE]

Bsquare has officially announced that they are porting Adobe’s Flash Lite 3.17 technology onto Dell Netbooks running Google’s Android platform. Integrating Adobe Flash technology with the functionality of Google’s Android

News and Rumors

Swappa expands to wearables, get your gently used futuristic watches now

Swappa, a marketplace of gently used smartphone and tablets, recently started expanding its offerings to smartwatches, which are becoming a norm in the world of technology. If you head over to

9 Comments

  1. Jeffrey S
    January 10, 15:33 Reply

    This works, but results in a quick “flash” of the title bar when launching the app, before those flags are called. To prevent this flash, define a new theme like this:

    true

    Then apply it to the activity:

    This makes your app do the same thing, but without the unsightly title bar flash before it’s removed in Java. :)

  2. Romain Guy
    January 10, 16:03 Reply

    As a rule of thumb, anything you do to modify the appearance of the window should preferably be done with a theme. For instance, if you set your own background in your window, define the background in the theme. This will make the launch appear smoother and faster.

  3. Mark Murphy
    January 10, 16:26 Reply

    Help! My blog post is being invaded by Googlers!

    😉

    Seriously, thanks guys! I remembered there was a theme floating around somewhere that handled this, but blanked on it when writing the post.

    Thanks again!

  4. Romain Guy
    January 11, 02:12 Reply

    I plan on writing a blog post about how to use theme to improve perceived launch performance. We use this “trick” in the Maps application for instance.

  5. Professor
    January 11, 05:10 Reply

    Мог бы долго с вами спорить на эту тему :)

  6. Dianne
    January 12, 03:45 Reply

    You actually don’t need to make your own theme, there are some standard variations on the basic themes for this kind of stuff. For example, if you are using the default Theme, you could use android:theme=”@android:style/Theme.NoTitleBar” to not have a title bar. Likewise there is Theme.NoTitleBar.Fullscreen for no title bar and no status bar.

Leave a Reply