How to create an application without a title bar?

Asked

Viewed 235 times

2

I intend to create a web app with a WebView. How can I create an application without a title bar that isn’t fullscreen?

  • Sem Action Bar?

  • do not know the right name, without the bar where display the title of the application and where you can have the icon to open the menu etc

  • In which android version?

2 answers

3


There are several ways, one of them is to define using the Window.FEATURE_ACTION_BAR passing by getActionBar().hide() in his Activity:

Programmatically

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    getActionBar().hide();

Using windoActionBar in XML

In the res/styles.xml you can do it this way:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Using the Noactionbar theme feature

But it can also be done this way by disabling the ActionBar provided by the theme. The easiest way is to have your theme extend from Theme.AppCompat.Noactionbar (or the light variant) inside the file res/styles.xml:

<resources>
  <!-- Base application theme. -->
  <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
  </style>
</resources>

Details

1

Change this part of your Androidmanifest

   ...
    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme" >
        <activity
            android:screenOrientation="portrait"
            android:name=".Principal"
            android:theme="@android:style/Theme.Holo.Light.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

The important thing is this line:

 android:theme="@android:style/Theme.Holo.Light.NoActionBar">

Browser other questions tagged

You are not signed in. Login or sign up in order to post.